This is a Google Script to get the Twitter follower numbers for selected Twitter handles in a Google Sheet. The follower numbers are outputted in a new tab of the same Google Sheet.
This script is set up as a Google Script addon but isn't deployed, which makes the process of running it a little involved...
You'll need to set this up as a standalone Google Script in Google Drive as then test it as an add-on to actually run the script:
- Create new blank Google script in Google Drive (not as part of a spreadsheet but standalone)
- Paste the above code into the script and save it
- Replace '##############' in the config object with your consumer key and consumer secret (lines 13-14) from https://apps.twitter.com/
- Add the OAuth1 library as explained in the "Setup" section here https://github.com/googlesamples/apps-script-oauth1
Test as addon:
- click Publish >> Test as addon
- Create a new test: select "Test with latest code", "Installed and enabled" and then for "Select doc" choose a Google Sheet file
- Click Save and then select the test you just created and click "Test"
You'll be redirected to the selected Google Sheet where you can run the addon:
- Select the cells with the Twitter handles in
- Click Addons >> [name you gave the code file] >> Get Twitter Followers
- Authorise the app with Google
- Login to Twitter when redirected to authorise there
- ... finally, go back and select the cells with the Twitter handles in again
- Click Addons >> [name you gave the code file] >> Get Twitter Followers
- The data for the Twitter followers will be published in a new tab in the same sheet!
Please see the file called LICENSE.