Instagram feed based on tag and geolocation

戏子无情 提交于 2019-12-30 02:32:10

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!