### Administration - npds_twitter

This module requires to open a twitter account and to create a Twitter application for the use of the APIs on your site.
- If you have not these elements, follow the procedure I below.

#### I.Twitter procedure

##### Registration

1. Register as user HERE
2. Register as developer ICI.

##### Create the application

1. Create the application (bridge between NPDS and Twitter) HERE:
During the creation of the application, informations to enter are:

- App Name: Name of your choice for your application (example, "NDPS-Twi bridge." Only one restriction: Must not contain the word "twitter")
- Application description: Same, free entry. For example: "bridge NPDS-Twitter"
- Website URL: the url of the site on which you install npds_twi
- Tell us how this app will be used: for example : "This application will be used to automatically publish tweets when there is new publication in our CCMS."
- The others fields are not required.

2. Setting the twitter application:

- Once the application is created, go to the "Settings" tab of the application.
- In the "Application type" section, for the parameter "Access", check "Read and write."
- Click on "Update this Twitter application's settings" to confirm.
- Cliquez on the "Details" tab.
- Click on "Create my access token". If this is already done, then click on \"Recreate my access token\"
  Warning! This will change the keys "Access token". If you have already entered them earlier in npds_twi, you must have to re-enter.

3. Grab your keys and tokens (required for setting up your module).

4. You now have the elements necessary for the operation of the bridge:

- Your Consumer key (Consumer key)
- Your consumer secret (Consumer Secret)
- Your token for Open Authentication (Access token)
- Your secret token for Open Authentication (Access token secret)

#### II. Npds Procedure

Go to the module administration
`/admin.php?op=Extend-Admin-SubModule&ModPath=npds_twi&ModStart=admin/npds_twi_set`

- A message will inform you if the publication is authorized for the site (default to No). (to modify this higher authorization follow the link) `/admin.php?op=Configure`
  Preferences > Configuration for Backend & Social Networks > Activate Twitter
- Activate or not the publication of news on twitter
- Choose a url shortcut
- Fill in the 4 fields with the twitter settings (cf4)

##### Tip

If you want to use npds_twi on several NPDS sites, but with a single twitter account, you should create a twitter application for each NPDS site. This will allow you to properly inform the callback url and WebSite url each time.
There are three solutions implemented to shorten urls without going through an external service.
Two of these solutions (cf.b cf.c) use a .htaccess file the other is only in php and native for NPDS (cf.a)

- a - The recommended solution (checked by default) is: Url rewriting with Npds controleur
- b - If you choose: Url rewriting with mod_rewrite
  You must modify (or create if it does not exist) the .htaccess file (at the root of your site) as follows:
  `RewriteEngine on
  RewriteRule ^s([0-9]+)$ /article.php?sid=$1[L]`
  Note: the first line is useless if it already exists in your file, the second line is required.
- c - If you choose: Url rewriting with ForceType
  You must modify (or create if it does not exist) the .htaccess file (at the root of your site) as follows:
  `<FilesMatch "^s$">
  ForceType application/x-httpd- php
  SetHandler application/x-httpd-php
  </FilesMatch>`

npds_twitter - Manuel administration