我可以在没有Instagram API或访问令牌的情况下从Instagram个人资料中获取图像吗?
答案 0 :(得分:12)
你可以获得所有图像。只需按page_info
进行迭代即可。另外,有更方便的方法来获取json:
$otherPage = 'nasa';
$profileUrl = "https://www.instagram.com/$otherPage/?__a=1";
$iterationUrl = $profileUrl;
$tryNext = true;
$limit = 100;
$found = 0;
while ($tryNext) {
$tryNext = false;
$response = file_get_contents($iterationUrl);
if ($response === false) {
break;
}
$data = json_decode($response, true);
if ($data === null) {
break;
}
$media = $data['user']['media'];
$found += count($media['nodes']);
var_dump($media['nodes']);
if ($media['page_info']['has_next_page'] && $found < $limit) {
$iterationUrl = $profileUrl . '&max_id=' . $media['page_info']['end_cursor'];
$tryNext = true;
}
}