Setting Up the Twitter Integration

Civic Platform’s integration with Twitter enables agency users to post Twitter comments, also known as “tweets,” from within the Civic Platform interface, by triggering certain EMSE events. For example, you can configure the EMSE event, ApplicationSubmitAfter, to automatically tweet record details upon record creation.

Before you can begin using the Twitter integration you must follow each of the procedures listed below. Do not skip any steps unless they are optional.

Topics

Enabling Function ID 0347-Social Media

Before you can configure and use this feature, you must enable it by setting Function ID 0347-Social Media. For complete instructions on setting a Function ID, refer to “Working With FIDs and Standard Choices” in the Accela Civic Platform Configuration Reference.

Creating a Twitter Account for Your Agency

Establish a Twitter account that represents your agency if your agency does not already have one. The Twitter account you create for your agency enables users to tweet information from within Civic Platform, using this agency-wide, group Twitter account.

To create an agency-wide Twitter account

  1. Go to https://dev.twitter.com.

  2. Choose a Twitter name for your agency that represents a public image that citizens can recognize and identify with your agency.

    The Twitter account you configure in this step becomes the Twitter account you use for generating the access token key and secret in the next procedure.

  3. Complete the registration process.

Generating the Access Token Key and Secret

Generate an access token key and an access token secret from Twitter and register them in Civic Platform. The token key and the token secret become the login credentials users enter to post Twitter messages from within Civic Platform.


Note:

All users at the same Civic Platform website share the same access token key and access token secret. Users post messages to the same Twitter account that the administrator uses to generate the access token key and access token secret.


To generate the access token key and access token secret

  1. Go to Civic Platform Administration > System Tools > Social Media.

    Civic Platform displays the Social Media administration portlet.



  2. Click Generate.

    Civic Platform displays the Access Token Generator page.



  3. Click Get PIN Code.

    Civic Platform redirects you to the Twitter authorization entry page.



  4. Enter your Twitter account credentials, and then click Authorize app.

    Twitter provides the PIN code.



  5. Enter the PIN code in the Access Token Generator page, and then click Generate.

    Civic Platform displays the access token key and access token secret.



  6. Return to the Social Media administration portlet, and enter the Twitter connection details.



    Access Token Secret The access token secret that displays in the Access Token Generator page.
    Access Token Key The access token key that displays in the Access Token Generator page.
    Proxy Host Optional. The host address of the proxy server that you plan to use for posting tweets.
    Proxy Port Optional. The port of the proxy server that you plan to use for posting tweets.
  7. Click Save.

    Civic Platform saves the access token secret and access token key for posting tweets.

Customizing the Twitter Account Name

To change the Twitter account name from Civic Platform to your agency’s Twitter account name, after generating your access token key and access token secret in Twitter, you must configure the related Standard Choice.

Table 1. Standard Choices Configuration
Name New/Existing Level Standard Choice values Value Description Description
SOCIAL_ MEDIA_ SETTINGS New Agency TWITTER CONSUMER_KEY=*****, CONSUMER_SECRET= ***** The Standard Choice registers the consumer key and consumer secret you get from the Twitter site. Replace the “*****” in the Value Desc with the actual consumer key and consumer secret strings.

Configuring EMSE Methods for Twitter Integration

Civic Platform uses EMSE methods for posting tweets. With the methods, users can read and post Twitter comments from within Civic Platform.

The following EMSE method posts messages to twitter:

ScriptResult post(String providerCode, String url, Map<String, Object> params)
The following EMSE method generates an empty Map object into which you can put the parameters (
params)
:
Accela Automation.oAuthClient.initPostParameters()

Sample Script and Sample Tweet

Topics:

Sample POST Request Script

This sample script posts the message “A message from Accela!” to Twitter:

//Sample of Post request 
function updateTwitterStatus() 
{ 
var client = Accela Automation.oAuthClient; 
var oauthProviderCode = 'TWITTER'; 
var url = 'https://api.twitter.com/1/statuses/update.json'; 
var params = client.initPostParameters(); 
params.put('status', 'A message from Accela!'); 
var scriptResult = client.post(oauthProviderCode, url, params); 
if (scriptResult.getSuccess()) 
         { 
Accela Automation.print(“Success: “ + scriptResult.getOutput()); 
      } 
else 
     { 
Accela Automation.print(“Failure: “ + scriptResult.getErrorMessage()); 
         }           
} 

Sample Tweets Posted from Civic Platform

Associate the Sample POST Request Script with the ApplicationSubmitAfter event. When users create a new application and save it, it triggers the ApplicationSubmitAfter event. The following tweets display on the Twitter account for which you configured the access token key and secret.