如何从消费instagram API的地方获取Instagram图片?

时间:2014-04-07 00:57:01

标签: javascript api instagram

我看了instafeed.js。它立即运行良好,我按照第一个文档,在网页上显示了20个图像样本。

但是我真的需要从某个地方(城市,在我的情况下)获取图片。使用Twitter API我曾经为想要的地方寻找WOEID。这里似乎很相似。

我看了Instagram docs

DISTANCE    Default is 1000m (distance=1000), max distance is 5000.
FACEBOOK_PLACES_ID  Returns a location mapped off of a Facebook places id. If used, a Foursquare id and lat, lng are not required.
FOURSQUARE_ID   Returns a location mapped off of a foursquare v1 api location id. If used, you are not required to use lat and lng. Note that this method is deprecated; you should use the new foursquare IDs with V2 of their API.
LAT Latitude of the center search coordinate. If used, lng is required.
LNG Longitude of the center search coordinate. If used, lat is required.
FOURSQUARE_V2_ID    Returns a location mapped off of a foursquare v2 api location id. If used, you are not required to use lat and lng.

但我到底能在哪里获得这样一个城市的身份证。让我们说我想要在墨西哥普埃布拉用晚餐标记的照片。我该怎么办。

我使用这个不错的网站从我的坐标中获取ID:http://maihamakyo.org/etc/locastagram/index.php

然后尝试了这个Java Script代码:

var feed = new Instafeed({
                get: 'tagged',
                location: '46016173',
                tagName: 'CLEU',
                clientId: '***'
})

feed.run();

但没有得到预期的结果。

2 个答案:

答案 0 :(得分:2)

从版本 1.3 开始,您可以向Instafeed.js添加过滤功能,以从结果中排除图片。

因此,您应该可以设置get: "location"locationId,然后过滤掉包含您要查找的标记的所有图片:

var feed = new Instafeed({
  get: 'location',
  locationId: LOC_ID,
  // other settings omitted for example
  filter: function(image) {
    return image.tags.indexOf('TAG_NAME') >= 0;
  }
});
feed.run();

<强>更新

传递给image函数的filter参数是直接来自Instagram API的图像数据。因此,您可以根据需要过滤任何条件。只需确保该函数返回truefalse

filter: function(image) {
  if (image.tags.indexOf('TAG_NAME') >= 0 && image.filter === "Normal") {
    return true;
  }
  return false;
}

要了解image对象具有哪些属性,请在GitHub上查看this thread

答案 1 :(得分:1)

查看instafeed.js documentation,地理位置的选项名称/键应为locationId

我不熟悉Instagram API,但是instafeed.js文档强烈暗示get需要设置为location才能使用位置ID。因此,您很可能只能搜索标签或位置,但不能同时搜索两者。