[英]Get Request Working fine with Postman but not with PHP CURL
我對 postman 有簡單的 GET 請求,它工作正常https://www.instagram.com/p/CVhuRABqnAI/?__a=1&__d=dis
當我使用 PHP CURL 時,它沒有用 Json 數據回應我,而是顯示徽標
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_USERAGENT => "Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0",
CURLOPT_URL => "https://www.instagram.com/p/CVhuRABqnAI/?__a=1&__d=dis",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
$error = curl_error($curl);
curl_close($curl);
if($error) {
echo "cURL Error:" . $error;
} else {
echo $response;
}
別人可以用這個嗎?
最后我可能知道該怎么做,因為我剛剛遇到了這個問題。
通常,postman 和 curl 之間存在某種差異。 或者還有其他“東西”,因為我的解決方案是根本不發送任何標題......
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.