问题描述
我想使用 PHP 从 Instagram 获取带有特定哈希标签的所有图片.我该怎么做?
I want to get all the pictures with a specific hash tag from Instagram using PHP. How can I do that?
推荐答案
首先,Instagram API 端点标签"需要 OAuth 身份验证.
Firstly, the Instagram API endpoint "tags" required OAuth authentication.
您可以使用以下网址查询特定主题标签(在本例中为下雪)的结果
You can query results for a particular hashtag (snowy in this case) using the following url
速率限制为每小时 5000 (X-Ratelimit-Limit:5000)
It is rate limited to 5000 (X-Ratelimit-Limit:5000) per hour
https://api.instagram.com/v1/tags/snowy/媒体/近期
示例响应
{
"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"
}
}
}
你可以在这里玩:
您需要使用身份验证"作为 OAuth 2,系统会提示您通过 Instagram 登录.发布您可能需要在模板"部分重新输入标签名称".
You need to use "Authentication" as OAuth 2 and will be prompted to signin via Instagram.Post that you might have to reneter the "tag-name" in "Template" section.
所有与分页相关的数据都可以在响应中的pagination"参数中找到,并使用它的next_url"来查询下一组结果.
All the pagination related data is available in the "pagination" parameter in the response and use it's "next_url" to query for the next set of result.
这篇关于Instagram API 获取带有特定主题标签的图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!