以下是我正在使用的代码
$decode = json_decode($json, true);
var_dump($decode);
结果如下:
c.ak.instagram.com/hphotos-ak-xfa1/10666256_719752088073218_1127882203_a.jpg"
["full_name"]=> string(26) "Promote OLShop Harga Murah" ["bio"]=> string(0) "" ["id"]=>
string(9) "356515767" } } } }
如何获取媒体ID?示例结果:
817757393383064097_356515767
请帮帮我。
答案 0 :(得分:0)
$json = file_get_contents('https://api.instagram.com/v1/tags/gaul/media/recent?access_token=1463408808.e757b44.0738048e481448b48f1cbb23f70f0195&count=1');
$decode = json_decode($json, true);
$media_id = $decode['data'][0]['id']
答案 1 :(得分:0)
如果你看一下Embedding,你会找到一个合适的答案,对我来说,我需要一个项目的media_id
,所以我把它包装成一个函数
function getMediaID($permalink) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.instagram.com/oembed?url=' . $permalink);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$oembed = curl_exec($ch);
curl_close($ch);
$oembed = json_decode($oembed, true);
return $oembed['media_id'];
}
答案 2 :(得分:0)
您展示的结果是获取USER数据...而不是媒体。要让媒体使用像:
https://api.instagram.com/v1/users/USERID/media/recent/?access_token=TOKEN&count=COUNT
其中:
答案 3 :(得分:0)
<?php
$permalink = $_GET["url"];
getMediaID($permalink) ;
function getMediaID($permalink) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.instagram.com/oembed?url=' . $permalink);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$oembed = curl_exec($ch);
curl_close($ch);
$oembed = json_decode($oembed, true);
echo $oembed['media_id'];
return $oembed['media_id'];
}
?>
&#13;
答案 4 :(得分:0)
您将使用:
$search_response = curlRequest("get", "https://api.instagram.com/v1/users/self/media/recent/?access_token={$json_data['access_token']}");
然后:
$photo_id= $search_response['data'][$i]['id'];
echo $photo_id .'<br/>';
($i for exapmle data[1] , data[2] etc.) - (each image data)