Instagram 获取最近的媒体返回不推荐\u警告

Instagram 获取最近的媒体返回不推荐\u警告,instagram,instagram-api,Instagram,Instagram Api,我为这个问题花了几个小时,这让我发疯 我有访问令牌,除了最近标记的媒体端点外,它可以正常工作。 我用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_set

我为这个问题花了几个小时,这让我发疯

我有访问令牌,除了最近标记的媒体端点外,它可以正常工作。 我用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>';

而另一个API似乎工作得很好。instagram标记的媒体API是否工作不正常?有人遇到此问题吗?

状态为200,您的请求正常。问题是你的应用程序仍然处于沙盒模式。这将只返回您在沙箱中添加的用户的数据

从Instagram网站:

Instagram平台和文档更新。2015年11月17日当天或之后创建的应用程序将以沙箱模式启动,并根据最新更新的API速率限制和行为运行。在上线之前,这些应用程序必须经过一个新的审查流程,才能供应用程序开发者以外的人使用。有关更多详细信息,请阅读API文档或更改日志

2015年11月17日之前创建的任何应用程序将继续运行到2016年6月1日。在该日期,如果未通过审查流程批准,该应用程序将自动移动到沙箱模式。我们的文档的前一个版本仍然可以在这里找到

您需要再次通过应用程序审查流程来接收新的API密钥,其中包括提供所需API权限的说明,并通过提交的视频演示如何使用这些权限


更多有关Instagrams的详细信息由于Instagrams的最新更新,您无法再通过标签获取最新图像

但我已经做了一个变通办法,可以帮助你解决你的问题

请在

函数getImagesByHashtag($hashtag,$ran\u count=16){ $crawl=文件\u获取\u内容(“https://www.instagram.com/explore/tags/$hashtag/”; $crawl=(str_replace(“window.\u sharedData=”,“”,strstrstr($crawl,“window.\u sharedData=”))); $crawl=substr($crawl,0,strpos($crawl,;'); $crawl=json_解码($crawl); $end\u cursor=($crawl->entry\u data->TagPage[0]->tag->media->page\u info->end\u cursor); $images=$crawl->entry_data->TagPage[0]->tag->media->nodes; $more=array(); 如果($ran_count>16){ $count=$ran\u count-16; $url=”https://www.instagram.com/query/?q=ig_hashtag($hashtag)+%7B+媒体。在($end_游标%2C+$count)之后+%7.7%7%0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0计数%0A++++%7D%2C%0A+++++owner++%7B%0A+++id%0A++++%7D%2C%0A+++++summable_src%2C%0A++++视频视图%0A++%7D%2C%0A++页面信息%0A%7D%0A++%7D&ref=tags%3A%3Ashow”; $more=json_解码(文件获取内容($url)); $more=$more->media->nodes; } 返回数组合并($images,$more); }
谢谢您的回复。但这不是很荒谬吗?如果我甚至不能开始使用API来构建它,我该如何开发和记录它呢。
{"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": []}
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);
}