繁体   English   中英

如何使用instagram API?

[英]How work with instagram API?

我开始使用Instagram API。 我想从一个标签获取所有照片。 为此,我使用这样的api链接:

http.api.instagram.com/v1/tags/test/media/recent&access_token=...

结果我在JSON中有这样的响应:

    {
  "pagination": {
    "next_min_id": "AQDPw33Vz6ZgxgHuZ8umA1c_Xavrys6Vuj61KqoUvr54ADSI7LKvBcx_MecQgyvaR-JrhO_s5DUAgkjFzHrGLidBZPUhxU4zi6iaNA1UeWQJVA",
    "min_tag_id": "AQDPw33Vz6ZgxgHuZ8umA1c_XavryJ6Vuj61KqoasdADSI7LKvBcx_MecQgyvaR-JrhO_s5DUAgkjFzHrGLidBZPzxcU4zi6iaNA1UeWQJVA",
    "deprecation_warning": "next_max_id and min_id are deprecated for this endpoint; use min_tag_id and max_tag_id instead"
  },
  "data": [
    {
      "id": "1626816542803445150_32412343357",
      "user": {
        "id": "3241233357",
        "full_name": "test",
        "profile_picture": "https:\/\/scontent.cdninstagram.com\/t51.2885-19\/s150x150\/1626816542803445150_32412343357_a.jpg",
        "username": "test_software"
      },
      "images": {
        "thumbnail": {
          "width": 150,
          "height": 150,
          "url": "https:\/\/scontent.cdninstagram.com\/t51.2885-15\/s150x150\/e35\/1626816542803445150_32412343357.jpg"
        },
        "low_resolution": {
          "width": 320,
          "height": 320,
          "url": "https:\/\/scontent.cdninstagram.com\/t51.2885-15\/s320x320\/e35\/1626816542803445150_32412343357.jpg"
        },
        "standard_resolution": {
          "width": 640,
          "height": 640,
          "url": "https:\/\/scontent.cdninstagram.com\/t51.2885-15\/s640x640\/sh0.08\/e35\/1626816542803445150_32412343357.jpg"
        }
      },
      "created_time": "141151666",
      "caption": {
        "id": "17879771646166136",
        "text": "#test",
        "created_time": "1508666666",
        "from": {
          "id": "3249481157",
          "full_name": "test",
          "profile_picture": "https:\/\/scontent.cdninstagram.com\/t51.2885-19\/s150x150\/1626816542803445150_32412343357.jpg",
          "username": "test_software"
        }
      },
      "user_has_liked": false,
      "likes": {
        "count": 1
      },
      "tags": [
        "test"
      ],
      "filter": "Moon",
      "comments": {
        "count": 0
      },
      "type": "image",
      "link": "https:\/\/www.instagram.com\/p\/BaTn124h0We\/",
      "location": null,
      "attribution": null,
      "users_in_photo": [

      ]
    },
   ....
  ],
  "meta": {
    "code": 200
  }
}

如何正确解析所有数据?

Instagram获得JSON,每页15条帖子。

解析当前15个帖子后如何获得下15个帖子?

如果我理解我必须解析next_mid_id字段,并使用该字段发送下一个响应。 这是正确的?

使用file_get_contents()检索提要的内容,然后使用json_decode()将提要返回的字符串转换为对象。

$json_source = file_get_contents('http.api.instagram.com/v1/tags/test...');

$json_data = json_decode($json_source);

var_dump($json_data);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM