Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/260.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP-如何在没有API访问令牌的情况下从Instagram获取图像_Php_Instagram - Fatal编程技术网

PHP-如何在没有API访问令牌的情况下从Instagram获取图像

PHP-如何在没有API访问令牌的情况下从Instagram获取图像,php,instagram,Php,Instagram,我可以在没有Instagram API或访问令牌的情况下从Instagram配置文件中获取图像吗?您可以获取所有图像。只需通过page\u info对它们进行迭代即可。此外,还有更方便的获取json的方法: $otherPage = 'nasa'; $profileUrl = "https://www.instagram.com/$otherPage/?__a=1"; $iterationUrl = $profileUrl; $tryNext = true; $limit = 100; $fo

我可以在没有Instagram API或访问令牌的情况下从Instagram配置文件中获取图像吗?

您可以获取所有图像。只需通过
page\u 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;
    }
}
$otherPage='nasa';
$profileUrl=”https://www.instagram.com/$otherPage/?\uu a=1”;
$iterationUrl=$profileUrl;
$tryNext=true;
$limit=100;
$found=0;
while($tryNext){
$tryNext=false;
$response=file\u get\u contents($iterationUrl);
如果($response==false){
打破
}
$data=json_decode($response,true);
如果($data==null){
打破
}
$media=$data['user']['media'];
$found+=计数($media['nodes']);
变量转储($media['nodes');
如果($media['page_info']['has_next_page']&&$found<$limit){
$iterationUrl=$profileUrl.&max_id='.$media['page_info']['end_cursor'];
$tryNext=true;
}
}

Instagram,他们将公共json的结构从$data['user']['media']更改为$data['graphql']['user']['edge\u owner\u to\u timeline\u media']['edges']:(下一页值没有返回相同的页面图像)