Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bran921007/629c0c83d7837302008082d8067e8935 to your computer and use it in GitHub Desktop.
Save bran921007/629c0c83d7837302008082d8067e8935 to your computer and use it in GitHub Desktop.
function initFollowerCount() {
// sets up sheet names and Instagram accounts
insertFollowerCount("sheet1", "kingandmcgaw");
insertFollowerCount("sheet2", "nickboyce");
}
function insertFollowerCount(sheetName, instagramAccountName) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName(sheetName);
sheet.appendRow([Utilities.formatDate(new Date(), "GMT", "yyyy-MM-dd"), getInstagramFollowerCount(instagramAccountName)]);
}
function getInstagramFollowerCount(username) {
var url = "https://www.instagram.com/" + username + "/?__a=1";
var response = UrlFetchApp.fetch(url).getContentText();
return JSON.parse(response).user.followed_by.count;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment