我花了好几个小时在这个问题上,这让我发疯了。
我有访问令牌,除了最近标记的媒体端点外,它可以工作。我使用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是否工作不正常?有人有这个问题吗?
发布于 2016-06-07 12:28:36
状态为200,您的请求是可以的。问题是你的应用程序仍然处于沙箱模式。这将只返回您在沙箱中添加的用户的数据。
来自Instagram网站:
Instagram平台和文档更新。2015年11月17日或之后创建的应用程序将以沙盒模式启动,并在新更新的API速率限制和行为上发挥作用。在使用Live之前,为了能够被应用程序的开发者以外的人使用,这些应用程序必须经过一个新的评审过程。有关更多细节,请阅读API文档或更改日志。 任何在2015年11月17日之前创建的应用程序都将继续运行到2016年6月1日。在那一天,应用程序将自动移动到沙箱模式,如果它没有通过审核过程。我们以前版本的文档仍可在这里查阅。
您需要再次通过应用程序评审过程来接收新的API密钥,这涉及到对所需api权限的描述,并通过提交的视频演示如何使用这些权限。
关于http://instagram.com/developer的更多细节
发布于 2016-06-07 14:19:24
由于Instagram的新更新,您不能再通过hashtag获取最近的图像。
但我做了一个解决办法可以帮你解决你的问题。
在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);
}https://stackoverflow.com/questions/37673112
复制相似问题