Created
April 3, 2015 18:36
-
-
Save BetoFrega/567fe498b0878b783c28 to your computer and use it in GitHub Desktop.
Count likes and comments posts Instagram
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function puxa() { | |
//Creating Variables | |
var userID = "xxxxxxxxxx"; | |
var access_token = "yyyyyyyyyy"; | |
var url= "https://api.instagram.com/v1/users/"+userID+"/media/recent?access_token="+access_token; | |
var ss = SpreadsheetApp.getActiveSpreadsheet(); | |
ss.insertSheet(); | |
var sheet = ss.getActiveSheet(); | |
var today = new Date(); | |
sheet.setName(today) | |
//Performing Calculation | |
content = UrlFetchApp.fetch(url); | |
var posts = JSON.parse(content).data; | |
for(i in posts) | |
{ | |
var obj = posts[i]; | |
var published = new Date(1970,0,1); | |
published.setSeconds(obj.created_time); | |
//Printing data in the SpreadSheet (link / likes / published / comments) | |
Logger.log(sheet.appendRow([obj.link,published,obj.likes.count,obj.comments.count])); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment