首页 > 解决方案 > PHP 使用 Instagram API 错误 HTTP 请求失败!HTTP/1.1 403 禁止

问题描述

我正在使用这样的网址: https ://www.instagram.com/graphql/query/?query_hash=42323d64886122307be10013ad2dcc44&variables=%7B%22id%22:%22555329715%22,%22first%22:12,%22after%22 :%22AQDea0aZ27W349lmEWRcuh9xz7sO2Elo-_RDymqEMzT85he8dFwkrV4lbKlii9z7AkWPEbLx_txFKKbHeuotw9c4fY40B-Mm-lF7sfWtq8PUfQ%22%7D

这个网址也可以在浏览器中使用,但代码如下:

        $insta_id = $ret->users[0]->user->pk;
    $link1 = "https://www.instagram.com/graphql/query/?query_hash=42323d64886122307be10013ad2dcc44&variables=%7B%22id%22:%22".$insta_id."%22,%22first%22:12,%22after%22:%22AQDea0aZ27W349lmEWRcuh9xz7sO2Elo-_RDymqEMzT85he8dFwkrV4lbKlii9z7AkWPEbLx_txFKKbHeuotw9c4fY40B-Mm-lF7sfWtq8PUfQ%22%7D";
    $response1 = file_get_contents($link1);

我在调用我的函数之前得到的是:

Message: file_get_contents(https://www.instagram.com/graphql/query/?query_hash=42323d64886122307be10013ad2dcc44&variables=%7B%22id%22:%22492948834%22,%22first%22:12,%22after%22:%22AQDea0aZ27W349lmEWRcuh9xz7sO2Elo-_RDymqEMzT85he8dFwkrV4lbKlii9z7AkWPEbLx_txFKKbHeuotw9c4fY40B-Mm-lF7sfWtq8PUfQ%22%7D): failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden

任何想法如何解决这个问题?非常感谢

标签: phpjsoninstagraminstagram-api

解决方案


推荐阅读