【问题标题】:PHP - How to get images from Instagram without API Access TokenPHP - 如何在没有 API 访问令牌的情况下从 Instagram 获取图像
【发布时间】:2016-11-28 02:00:07
【问题描述】:

我可以在没有 Instagram API 或访问令牌的情况下从 Instagram 个人资料中获取图片吗?

【问题讨论】:

    标签: php instagram


    【解决方案1】:

    您可以获得所有图像。只需通过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;
        }
    }
    

    【讨论】:

    • Instagram,他们将公共 json 的结构从 $data['user']['media'] 更改为 $data['graphql']['user']['edge_owner_to_timeline_media']['边缘'] :(
    • 下一页值没有返回相同的页面图像
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-23
    相关资源
    最近更新 更多