Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function fetchInsta() {
var lat = ;
var long = ;
var apikey = ;
var url = "https://api.instagram.com/v1/media/search?lat="+lat+"&lng="+long+"&distance=400&access_token="+apikey+"&count=100";
Logger.log(url);
var result = UrlFetchApp.fetch(url);
var json = JSON.parse(result.getContentText());
Logger.log(json);
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var existingids = sheet.getDataRange().getValues();
for(i in json.data){
var match = false;
for(j in existingids){
if(json.data[i].id === existingids[j][3].toString()){
var match = true;
}
}
if(match != true){
var image = json.data[i].images.standard_resolution.url;
var username = json.data[i].user.username;
var link = json.data[i].link;
var imageid = json.data[i].id;
var date = json.data[i].created_time;
sheet.appendRow([image,username,link,imageid,date]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.