The present post explains how to connect to twitter using their API to download the list of followers of a twitter account. The solution is based on a script in nodejs that uses this npm module and mongodb.
This solution is based on the assumption that you have the consumer key, consumer secret, access token key, and access token secret of a twitter account. The script uses the steps 1 and 4 stated on the instructions of the module, and since steps 2 and 3 are responsible for requesting the token key and secret that we assume you already have, they are irrelevant.
You have nodejs installed - note that every installation of Sisense contains an instance of nodejs in C:\Program Files\Sisense\PrismWeb\vnext\iisnodeModule
1. download the install node-twitter-api module from github from this url and unzip it in C:\Program Files\Sisense\PrismWeb\vnext\iisnodeModule\node_modules. Make sure to change the directory name to "node-twitter-api" after you unzip it.
2. see the nodejs script attached for a working example. Place it on the same folder where nodejs is installed and make sure to complete the parameters at the top according to your case. See screenshot below for reference:
3. to execute the script, in the command line pointing to the folder where nodejs is installed, type
4. in this example, after completing the authentication process the script downloads the list of followers and stores it in the same instance of mongodb that Sisense uses. It creates a new database called "test_insert" (you can change the name on line 51). See this page for more details on the get request.
5. follow the steps of connecting Sisense to mongodb here.
6. use the Elasticube to query one of the tables - I've used the table 'vt_users'
Note that this script will download the first 20 items of the result. To implement navigation of the result, see this resource from twitter developers forum.
Please sign in to leave a comment.