3.4.7 Twitter

This section allows you to configure Twitter as a data source, and subsequently pull unstructured posts from specific Twitter hashtags.

For you to be able to pull tweets based on hashtags, you will need to set up your Ushahidi deployment as an application on Twitter. To get started,

  • Click on the drop-down icon on the right as shown

Settings - Datasources: Button to open the Twitter datasource configuration
Settings - Datasources: Button to open the Twitter datasource configuration
Twitter website: create a new twitter application.
Twitter website: create a new twitter application.
Splashcreen for Subscriptions/Sign In/Developer Portal
  • Once you select the Developer Portal, you will be directed to your portal immediately. If you haven't created a developer's profile yet, you will be redirected to sign up for one as shown in the picture below:

The page where the user signs up for a new Developer's Profile
  • From here, you can choose either to Sign up for Free Account or choose one of the paid tiers to subscribe to. Note that the free tier limits the feature sets offered in these other paid tiers. Check their website for more information: https://developer.twitter.com/en/docs/twitter-api/getting-started/about-twitter-api

  • Once you select the option Sign up for Free Account, you will need to describe your use cases and also agree to the terms and conditions stipulated.

Developer agreement and policy page
  • Once you have filled in your description and checked all the boxes, click Submit.

Chechboxes and Submit button under the Developers Agreement and Policy
  • Once you click Submit, your developer account will automatically be created and you will be redirected to the Developer's Portal. Here, you will find out that Twitter/X has already created a project for you together with the app. You can proceed with this one, or you can delete the pre-made project and create yours afresh. If you decide to delete it, you can create a new one as shown below.

The page where a user creates a new project
  • Once selected, you should give your project a name

Describing the name of your project
  • Afterwards, select your use case for how you intend to use the platform

Describing the use case for your project
  • Provide a brief description of your project

Describe the project that is being created
  • Once you are done, you should click Next to set up your app.

To set up your app in this project, follow the steps below;

  • Select your App name.

You can enter the name of your deployment to make it more memorable.

Enter your App/Deployment/Project name
  • Click on Next to generate your keys and token.

The page that displays your API Key, API Key Secret and Bearer Token
  • Here, you will see the API Key, API Key Secret, and the Bearer Token generated for your app. Make sure to master or note down these codes safely since you will use them when filling out the form in the Ushahidi Platform. These codes can be generated later on as we will see in the process down below. Keep in mind that regenerating these keys might need you to update your code for your app to work properly.

Note: The API Key and Secret Key are treated like passwords, therefore they should be memorized or saved in a secure location. If the security has been compromised/you forgot to save the keys, new ones can be generated.

Test application configuration on Twitter.

The overview page on Projects and Apps
  • You’ll get redirected to a page where you can grab details needed to configure your Ushahidi deployment i.e CONSUMER KEY, CONSUMER SECRET, ACCESS TOKEN, ACCESS TOKEN SECRET.

Grab your consumer access token & Secret and API key & Secret
  • Go back to your Twitter configuration page on your deployment and fill in all the details from your Twitter app management page.

Configuration page for Twitter in Ushahidi Platform
Configuration page for Twitter in Ushahidi Platform
  • On your Twitter developer account panel, click on Reveal API Key hint next to API key and Secret to display a hint of your API Key. If you had not captured these codes before, you will be required to generate new ones. Copy and paste them on your deployment API and secret fields.

Prompt that appears when you regenerate API Key and API Key Secret
  • On the same panel, you will see Access Token and Secret. You’ll have to generate an ACCESS TOKEN and ACCESS TOKEN SECRET by clicking on the Generate button.

  • Copy and paste them on your deployment ACCESS TOKEN and ACCESS TOKEN SECRET fields.

NB: if you save them without copying and pasting, you will be regenerating new ones.

  • Add the hashtags you want to pull tweets from in the Twitter Search Terms section. You can choose more than one hashtag, separated by a comma. It is recommended that short and clear hashtags be chosen.

  • Click on Save and this data source’s settings will be saved. Unstructured posts from Twitter will now get pulled into the platform.

Configure Twitter in the Ushahidi Platform

  • To enable/disable the Twitter data source, simply click on the green toggle.

  • If you’d like to edit your Twitter configuration, click on the Twitter option and make your changes. Once you are done click Save. You can also delete Twitter as a data source by selecting the delete button.

Delete Option for Twitter Datasource

You can also choose which survey you want to import the data source into and you can toggle the option of accepting survey submissions from this source.

Enable the twitter toggle in the datasource to get tweets into platform
Enable the twitter toggle in the datasource to get tweets into platform

It will only take a few minutes and the tweets will appear on your deployment.

Last updated