伙计们。
我编写了一个脚本来使用代理从某些链接中获取内容。如果您知道原因并有建议,请帮助我。谢谢
当我运行以下代码时,它会显示 400 错误代码。
$linkCheck = "https://www.uwgc.org/give/donor-networks/step-up-program/2016/03/14/oh-the-places-she's-going";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $linkCheck);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXYPORT, $workingProxy['port']);
curl_setopt($ch, CURLOPT_PROXYTYPE, 'HTTP');
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_PROXY, $workingProxy['ip']);
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $workingProxy['username'].':'.$workingProxy['password']);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,10);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
$data = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error_report= curl_getinfo($ch);
curl_close($ch);
if($httpcode != 200){
echo '<pre>' . $httpcode .'</pre>' ;
return null;
}else{
return $data;
}
预期行为:
获取给定链接的正确内容。