【发布时间】:2023-03-23 03:30:01
【问题描述】:
我有一个来自 json_decode url instagram https://www.instagram.com/username/?__a=1 使用 php 返回 Null 的问题
$newwul = "http://www.instagram.com/username/?__a=1";
$xo = connect($newwul);
$xx = json_decode($xo,true);
$endcount = $xx['logging_page_id'];
$userid = $xx['graphql']['user']['id'];
var_dump($xo);//return NULL
var_dump($xx);//return NULL
它们是我的函数连接
function connect($urlx){
$cookie_file_path = "cookies/c.txt";
$agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36";
$urlex = ($urlx);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $urlex);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'cookie:ig_cb=1; rur=PRN; mid=XV_v7gAEAAFbvgXMUd0PClkTvnla; csrftoken=fs1r3L5SxkJvrN6g2w239nhMgppQGVLc; urlgen="{\"185.56.80.156\": 43350}:1i2zL0:8TaH7yECjymjQH80LduQiFUJZE0"',
));
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);
curl_setopt($ch, CURLOPT_REFERER, $urlex);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,100);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
return $req = curl_exec($ch);
curl_close($ch);
}
请问有什么解决办法吗?
【问题讨论】:
-
因为您的连接函数返回空值。您可能无法使用 curl 连接到 Instagram。请重新检查 curl 的错误:php.net/manual/en/function.curl-error.php
-
Au Nguyen 谢谢你的回答 没有函数 connect() 我仍然有同样的问题 我认为链接中存在问题 例如 这个 url 没问题 ``` $newwul = "@ 987654323@"; $xo = 连接($newwul); $xx = json_decode($xo,true); $endcount = $xx['状态'];回声 $endcount; //REQUEST_DENIED ```
-
Au Nguyen 谢谢你的回答 没有函数 connect() 我仍然有同样的问题 我认为链接中有问题 例如 这个网址没问题link
-
我猜你已经达到了 Instagram 的请求速率限制,回复是
null。