2016-06-07 65 views
1

我花了几个小时了这个问题,它让我发疯了。获取最近的媒体回报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无法正常工作?任何人都有这个问题?

回答

1

的状态是200,你的要求是OK。问题是您的应用仍处于沙盒模式。这只会返回您在沙盒上添加的用户的数据。

从Instagram的网站:

Instagram的平台和文档更新。 2015年11月17日或之后创建的应用程序将以沙箱模式启动,并在新近更新的API速率限制和行为上发挥作用。在上线之前,除了应用程序开发人员之外的人员可以使用这些应用程序,这些应用程序将不得不经历一个新的审核流程。请阅读API文档或更改日志以获取更多详细信息。

二○一五年十一月十七日创建之前将继续运行,直到2016年在该日期6月1日,所有的应用程序,该应用程序将被自动如果没有通过审查程序批准转移到沙盒模式。以前版本的文档仍然可以在这里找到。

您将需要再次通过应用程序审阅过程以接收新的API密钥,其中包括提供所需的api权限说明以及演示如何通过提交的视频使用这些权限。在http://instagram.com/developer

+0

感谢您的答复。但是,这不荒谬,如果我甚至不能开始使用API​​来构建它,我想如何开发和记录它。 – roxes

+0

我认为这个deprecation_warning在API返回数据时也会出现。 –

1

更多细节由于Instagrams新的更新,你可以不再通过主题标签获取最近的图像。

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

检查出来的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); 
}