Instagram API获取带有特定主题标签的图片

我想使用 PHP 从 Instagram 获取所有带有特定哈希标签的图片。

我想使用 PHP 从 Instagram 获取所有带有特定哈希标签的图片。

15

首先,Instagram API 端点“标签”需要 OAuth 身份验证。

您可以使用以下 URL 查询特定主题标签的结果(在这种情况下为 snowy)

费率限制为每小时 5000 (X-Ratelimit-Limit:5000)

https://api.instagram.com/v1/tags/snowy/media/recent

样品响应

{
  "pagination":  {
    "next_max_tag_id": "1370433362010",
    "deprecation_warning": "next_max_id and min_id are deprecated for this endpoint; use min_tag_id and max_tag_id instead",
    "next_max_id": "1370433362010",
    "next_min_id": "1370443976800",
    "min_tag_id": "1370443976800",
    "next_url": "https://api.instagram.com/v1/tags/snowy/media/recent?access_token=40480112.1fb234f.4866541998fd4656a2e2e2beaa5c4bb1&max_tag_id=1370433362010"
  },
  "meta":  {
    "code": 200
  },
  "data":  [
     {
      "attribution": null,
      "tags":  [
        "snowy"
      ],
      "type": "image",
      "location": null,
      "comments":  {
        "count": 0,
        "data":  []
      },
      "filter": null,
      "created_time": "1370418343",
      "link": "http://instagram.com/p/aK1yrGRi3l/",
      "likes":  {
        "count": 1,
        "data":  [
           {
            "username": "iri92lol",
            "profile_picture": "http://images.ak.instagram.com/profiles/profile_404174490_75sq_1370417509.jpg",
            "id": "404174490",
            "full_name": "Iri"
          }
        ]
      },
      "images":  {
        "low_resolution":  {
          "url": "http://distilleryimage1.s3.amazonaws.com/ecf272a2cdb311e2990322000a9f192c_6.jpg",
          "width": 306,
          "height": 306
        },
        "thumbnail":  {
          "url": "http://distilleryimage1.s3.amazonaws.com/ecf272a2cdb311e2990322000a9f192c_5.jpg",
          "width": 150,
          "height": 150
        },
        "standard_resolution":  {
          "url": "http://distilleryimage1.s3.amazonaws.com/ecf272a2cdb311e2990322000a9f192c_7.jpg",
          "width": 612,
          "height": 612
        }
      },
      "users_in_photo":  [],
      "caption":  {
        "created_time": "1370418353",
        "text": "#snowy",
        "from":  {
          "username": "iri92lol",
          "profile_picture": "http://images.ak.instagram.com/profiles/profile_404174490_75sq_1370417509.jpg",
          "id": "404174490",
          "full_name": "Iri"
        },
        "id": "471425773832908504"
      },
      "user_has_liked": false,
      "id": "471425689728724453_404174490",
      "user":  {
        "username": "iri92lol",
        "website": "",
        "profile_picture": "http://images.ak.instagram.com/profiles/profile_404174490_75sq_1370417509.jpg",
        "full_name": "Iri",
        "bio": "",
        "id": "404174490"
      }
    }
}

你可以在这里玩:

https://apigee.com/console/instagram?req=%7B%22resource%22%3A%22get_tags_media_recent%22%2C%22params%22%3A%7B%22query%22%3A%7B%7D%2C%22template%22%3A%7B%22tag-name%22%3A%22snowy%22%7D%2C%22headers%22%3A%7B%7D%2C%22body%22%3A%7B%22attachmentFormat%22%3A%22mime%22%2C%22attachmentContentDisposition%22%3A%22form-data%22%7D%7D%2C%22verb%22%3A%22get%22%7D

您需要使用“身份验证”作为 OAuth 2,并将提示通过 Instagram 登录。发布您可能必须在“模板”部分中租用“标签名称”。

所有与分页相关的数据都可以在响应中的“pagination”参数中使用,并使用它的“next_url”来查询下一组结果。

11

还不可能使用多个标签搜索内容,因为现在只支持单个标签。

首先,Instagram API 端点“标签”需要 OAuth 身份验证。

这是不太真实的,你只需要一个 API-Key。只需register一个应用程序并将其添加到您的请求中。例如:

https://api.instagram.com/v1/users/userIdYouWantToGetMediaFrom/media/recent?client_id=yourAPIKey

另请注意,用户名不是 user-id。您可以查找 user-Id 的here.

如果您为每个标签启动一个请求并比较服务器上的结果,则搜索多个关键字的解决方法当然,这可能会降低您的网站速度,具体取决于您要比较的关键字数量。

6

看看这里为了开始:http://instagram.com/developer/

然后为了按标签检索图片,请看这里:http://instagram.com/developer/endpoints/tags/

从 Instagram 获取标签不需要 OAuth,因此您可以通过以下 URL 进行调用:

GET IMAGES https://api.instagram.com/v1/tags/{tag-name}/media/recent?access_token={TOKEN} SEARCH https://api.instagram.com/v1/tags/search?q={tag-query}&access_token={TOKEN} TAG INFO https://api.instagram.com/v1/tags/{tag-name}?access_token={TOKEN}

本站系公益性非盈利分享网址,本文来自用户投稿,不代表码文网立场,如若转载,请注明出处

(910)
如何在SUMO或FLOW中实现交通灯的最长队列优先规则
上一篇
使用WebXR的立体照片的VR幻灯片
下一篇

相关推荐

发表评论

登录 后才能评论

评论列表(27条)