Skip to content

Instantly share code, notes, and snippets.

@nickboyce
Last active December 13, 2018 01:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickboyce/eefdfb25c65529cfe3d13ba016e36625 to your computer and use it in GitHub Desktop.
Save nickboyce/eefdfb25c65529cfe3d13ba016e36625 to your computer and use it in GitHub Desktop.
function initTwitterFollowerCount() {
insertTwitterFollowerCount("IG followers", "nickboyce");
}
function insertTwitterFollowerCount(sheetName, username) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName(sheetName);
Logger.log(sheet.getRange("A1").getValue());
sheet.appendRow([Utilities.formatDate(new Date(), "GMT", "yyyy-MM-dd"), getTwitterFollowerCount(username)]); 
}
function getTwitterFollowerCount(username) {
var url = "https://cdn.syndication.twimg.com/widgets/followbutton/info.json?screen_names="+username;
var response = UrlFetchApp.fetch(url).getContentText();
return JSON.parse(response)[0].followers_count;
}
@LenaFR
Copy link

LenaFR commented Feb 21, 2018

I'm having issues getting this script to run correctly. I think the issue is in line two? Are you able to advise?

@nickboyce
Copy link
Author

@LenaFR – looks like the quotes got messed up. Try again with the updated gist.

@cvanciu
Copy link

cvanciu commented Oct 16, 2018

I'm also having issues getting this script to run correctly. It is still not registering the sheetname and username as specified in initTwitterFollowerCount() even though the quotes are updated. Any idea what would be happening?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment