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

标签 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。假设我想要在墨西哥普埃布拉用晚餐标记的照片。我该怎么办。

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

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

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

feed.run();

但没有得到预期的结果。

最佳答案

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();

更新

传递给 filter 函数的 image 参数是直接来自 Instagram API 的图像数据。所以你可以根据你想要的任何标准进行过滤。只需确保函数返回 truefalse:

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

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

关于javascript - 如何从使用 instagram API 的地方获取 instagram 图片?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22901985/

相关文章:

swift - 使用 Swift 在图像上显示标记的用户名

python - 如何在Instagram上刮喜欢

php - 在其他网站上显示我的数据库查询

c# - POSTMAN POST 请求返回不支持的媒体类型

python - 如何使用 python 请求登录 instagram?

javascript - 我的 JavaScript 函数由于某种原因无法运行

javascript - 同步发射事件是否不正确?

IE 中 window.opener 的 JavaScript 问题

javascript - Meteor Spacebars - 预期的标识符、数字、字符串、 bool 值或 null

javascript - 每次点击鼠标时谷歌地图都会刷新