问题
Is it possible to get an instagram feed based on both a tag and location?
I want all the images tagged with #stackExchange located in Johannesburg ( and surrounding radius of 100 km )
回答1:
There is no API to get feed with both tag and location, there are independent APIs for tag and location, but you cannot currently make a single call and get results filtered for both.
Tag API:
https://api.instagram.com/v1/tags/snow/media/recent?access_token=ACCESS-TOKEN
Location search API:
https://api.instagram.com/v1/media/search?lat=48.858844&lng=2.294351&access_token=ACCESS-TOKEN
You can make location API call cache and then manually look for tags, but this may be expensive on number of API calls.. here is an implementation of location search and then you can filter by keyword: http://www.gramfeed.com/instagram/map
回答2:
As krisrak said - you need to choose: either get by location and then filter by tag or get by tag and then filter by location. check instafeed.js - you can use this for example (get by location and then filter by tag):
var mylocation = 1234569; //must be a number!
var feed = new Instafeed({
get: 'location',
locationId: mylocation,
clientId: 'someId', //change this with the client id you get from Instagram
filter: function(image) {
return (image.tags.indexOf('myTag') >= 0);
}
});
feed.run();
You can find the location you want in google maps. right click the specific point on the map and choose "what's here?" - this will reveal the coordinates. now use this site to get the Instagram locationId.
Notice that image object has all the properties returned by the Instagram api, so you can get the tags, the location, comments... fora full list of fields look at returned media api (click on response button).
but just remember: filter function must return boolean!
来源:https://stackoverflow.com/questions/22068282/instagram-feed-based-on-tag-and-geolocation