Created
May 5, 2015 20:41
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 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