获取最近的媒体 return deprecation_warning
Get Recent Media return deprecation_warning
我为这个问题花了好几个小时,这让我发疯。
我有访问令牌,它适用于最近标记的媒体端点。
我使用 PHP:
调用它
$url = "https://api.instagram.com/v1/tags/omg/media/recent?access_token={ACCESS_TOKEN}";
$curl_connection = curl_init($url);
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
//Data are stored in $data
$data = json_decode(curl_exec($curl_connection), true);
curl_close($curl_connection);
echo '<pre>';
echo print_r($data);
echo '</pre>';
这是我得到的结果:
{"pagination": {"deprecation_warning": "next_max_id and min_id are deprecated for this endpoint; use min_tag_id and max_tag_id instead"}, "meta": {"code": 200}, "data": []}
虽然另一个 API 似乎工作正常,但除此之外。 instagram 标记的媒体 API 是否无法正常工作?有人遇到这个问题吗?
状态为200,您的请求OK。问题是您的应用程序仍处于沙盒模式。这只会 return 来自您在沙盒中添加的用户的数据。
来自 Instagram 网站:
Instagram Platform and documentation update. Apps created on or after Nov 17, 2015 will start in Sandbox Mode and function on newly updated API rate-limits and behaviors. Prior to going Live, and being able to be used by people other than the developers of the app, these apps will have to go through a new review process. Please read the API documentation or the Change Log for more details.
Any app created before Nov 17, 2015 will continue to function until June 1, 2016. On that date, the app will automatically be moved to Sandbox Mode if it wasn't approved through the review process. The previous version of our documentation is still available here.
您将需要再次完成应用审核流程才能收到新的 API 密钥,其中包括提供您需要的 api 权限的描述并演示如何使用这些权限提交的视频。
的更多详细信息
由于 Instagram 的新更新,您无法再通过主题标签获取最新图片。
但我已经制定了一个可以帮助您解决问题的解决方法。
在 Github
上查看
function getImagesByHashtag($hashtag, $ran_count= 16){
$crawl = file_get_contents("https://www.instagram.com/explore/tags/$hashtag/");
$crawl = (str_replace("window._sharedData = ", "", strstr($crawl, "window._sharedData =")));
$crawl = substr($crawl, 0, strpos($crawl, ';</script>'));
$crawl = json_decode($crawl);
$end_cursor = ($crawl->entry_data->TagPage[0]->tag->media->page_info->end_cursor);
$images = $crawl->entry_data->TagPage[0]->tag->media->nodes;
$more = array();
if($ran_count > 16) {
$count = $ran_count-16;
$url = "https://www.instagram.com/query/?q=ig_hashtag($hashtag)+%7B+media.after($end_cursor%2C+$count)+%7B%0A++count%2C%0A++nodes+%7B%0A++++caption%2C%0A++++code%2C%0A++++comments+%7B%0A++++++count%0A++++%7D%2C%0A++++date%2C%0A++++dimensions+%7B%0A++++++height%2C%0A++++++width%0A++++%7D%2C%0A++++display_src%2C%0A++++id%2C%0A++++is_video%2C%0A++++likes+%7B%0A++++++count%0A++++%7D%2C%0A++++owner+%7B%0A++++++id%0A++++%7D%2C%0A++++thumbnail_src%2C%0A++++video_views%0A++%7D%2C%0A++page_info%0A%7D%0A+%7D&ref=tags%3A%3Ashow";
$more = json_decode(file_get_contents($url));
$more = $more->media->nodes;
}
return array_merge($images, $more);
}
我为这个问题花了好几个小时,这让我发疯。
我有访问令牌,它适用于最近标记的媒体端点。 我使用 PHP:
调用它$url = "https://api.instagram.com/v1/tags/omg/media/recent?access_token={ACCESS_TOKEN}";
$curl_connection = curl_init($url);
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
//Data are stored in $data
$data = json_decode(curl_exec($curl_connection), true);
curl_close($curl_connection);
echo '<pre>';
echo print_r($data);
echo '</pre>';
这是我得到的结果:
{"pagination": {"deprecation_warning": "next_max_id and min_id are deprecated for this endpoint; use min_tag_id and max_tag_id instead"}, "meta": {"code": 200}, "data": []}
虽然另一个 API 似乎工作正常,但除此之外。 instagram 标记的媒体 API 是否无法正常工作?有人遇到这个问题吗?
状态为200,您的请求OK。问题是您的应用程序仍处于沙盒模式。这只会 return 来自您在沙盒中添加的用户的数据。
来自 Instagram 网站:
Instagram Platform and documentation update. Apps created on or after Nov 17, 2015 will start in Sandbox Mode and function on newly updated API rate-limits and behaviors. Prior to going Live, and being able to be used by people other than the developers of the app, these apps will have to go through a new review process. Please read the API documentation or the Change Log for more details.
Any app created before Nov 17, 2015 will continue to function until June 1, 2016. On that date, the app will automatically be moved to Sandbox Mode if it wasn't approved through the review process. The previous version of our documentation is still available here.
您将需要再次完成应用审核流程才能收到新的 API 密钥,其中包括提供您需要的 api 权限的描述并演示如何使用这些权限提交的视频。
的更多详细信息由于 Instagram 的新更新,您无法再通过主题标签获取最新图片。
但我已经制定了一个可以帮助您解决问题的解决方法。
在 Github
上查看function getImagesByHashtag($hashtag, $ran_count= 16){
$crawl = file_get_contents("https://www.instagram.com/explore/tags/$hashtag/");
$crawl = (str_replace("window._sharedData = ", "", strstr($crawl, "window._sharedData =")));
$crawl = substr($crawl, 0, strpos($crawl, ';</script>'));
$crawl = json_decode($crawl);
$end_cursor = ($crawl->entry_data->TagPage[0]->tag->media->page_info->end_cursor);
$images = $crawl->entry_data->TagPage[0]->tag->media->nodes;
$more = array();
if($ran_count > 16) {
$count = $ran_count-16;
$url = "https://www.instagram.com/query/?q=ig_hashtag($hashtag)+%7B+media.after($end_cursor%2C+$count)+%7B%0A++count%2C%0A++nodes+%7B%0A++++caption%2C%0A++++code%2C%0A++++comments+%7B%0A++++++count%0A++++%7D%2C%0A++++date%2C%0A++++dimensions+%7B%0A++++++height%2C%0A++++++width%0A++++%7D%2C%0A++++display_src%2C%0A++++id%2C%0A++++is_video%2C%0A++++likes+%7B%0A++++++count%0A++++%7D%2C%0A++++owner+%7B%0A++++++id%0A++++%7D%2C%0A++++thumbnail_src%2C%0A++++video_views%0A++%7D%2C%0A++page_info%0A%7D%0A+%7D&ref=tags%3A%3Ashow";
$more = json_decode(file_get_contents($url));
$more = $more->media->nodes;
}
return array_merge($images, $more);
}