首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何从使用instagram API的地方获取instagram图片?

如何从使用instagram API的地方获取instagram图片?
EN

Stack Overflow用户
提问于 2014-04-07 00:57:00
回答 2查看 2.9K关注 0票数 1

我看了看instafeed.js。它工作得很好,我跟踪了第一个文档,得到了一个在网页上显示的20个图像样本。

然而,我真的需要从某个地方(在我的例子中,城市)获取照片。使用Twitter时,我曾经为想要的地方寻找WOEID。这里的情况似乎很相似。

我读过Instagram文档

代码语言:javascript
运行
复制
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.

但我在哪能拿到这样的城市身份证呢。假设我想要在墨西哥普埃布拉用晚餐标记的照片。我该怎么办呢。

我使用这个很好的站点从我的坐标:http://maihamakyo.org/etc/locastagram/index.php获得一个ID

然后尝试了这个Java脚本代码:

代码语言:javascript
运行
复制
var feed = new Instafeed({
                get: 'tagged',
                location: '46016173',
                tagName: 'CLEU',
                clientId: '***'
})

feed.run();

但没有得到预期的结果。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-05-22 15:06:53

从版本1.3开始,您可以向Instafeed.js添加一个过滤器函数,以从结果中排除图像。

因此,您应该能够设置get: "location"locationId,然后筛选出不包含要查找的标记的任何图像:

代码语言:javascript
运行
复制
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

代码语言:javascript
运行
复制
filter: function(image) {
  if (image.tags.indexOf('TAG_NAME') >= 0 && image.filter === "Normal") {
    return true;
  }
  return false;
}

要了解image对象具有哪些属性,请检查GitHub上的这条线

票数 2
EN

Stack Overflow用户

发布于 2014-04-07 01:04:15

查看instafeed.js文档,位置的选项名称/键应该是locationId

我不熟悉Instagram API,但是instafeed.js文档很大程度上暗示了需要将get设置为location才能使用位置ID,因此很有可能您只能搜索标记或位置,而不能同时搜索两者。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22901985

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档