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

  • 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:

  • 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.

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

  • 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.

  • Once selected, you should give your project a name

  • Afterwards, select your use case for how you intend to use the platform

  • Provide a brief description of your project

  • 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.

  • Click on Next to generate your keys and 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.

  • 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.

  • Go back to your Twitter configuration page on your deployment and fill in all the details from your Twitter app management page.

  • 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.

  • 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.

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.

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

Last updated