cURL PHP 和 cURL
我有一个奇怪的问题。我正在大量使用 PHP cURL,但我有一个网站无法打开。
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
@unlink("/tmp/cookies.txt");
curl_setopt( $ch, CURLOPT_COOKIEFILE, "/tmp/cookies.txt");
curl_setopt( $ch, CURLOPT_COOKIEJAR, "/tmp/cookies.txt");
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1 );
curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 30 );
curl_setopt( $ch, CURLOPT_TIMEOUT, 30 );
curl_setopt( $ch, CURLOPT_HEADER, 0);
curl_setopt( $ch, CURLOPT_REFERER, "http://www.gmail.com");
curl_setopt( $ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/3.5.0.1");
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
$page = curl_exec( $ch );
$info = curl_getinfo($ch);
$info 返回:
[url] => MASKED
[content_type] =>
[http_code] => 0
[header_size] => 0
[request_size] => 0
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0
[namelookup_time] => 0
[connect_time] => 0
[pretransfer_time] => 0
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => -1
[upload_content_length] => -1
[starttransfer_time] => 0
[redirect_time] => 0
我在服务器上安装了常规 cURL。 所以如果我这样做 卷曲domain.com
它有效! 这是同一个域。 我尝试清除防火墙,并让 cURL 使用 FRESH_CONNECT,以便它提取该域的最新 IP。 还是不行。想法?
I'm having a strange issue. I'm working heavily with PHP cURL, and I have a website that I just can't open.
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
@unlink("/tmp/cookies.txt");
curl_setopt( $ch, CURLOPT_COOKIEFILE, "/tmp/cookies.txt");
curl_setopt( $ch, CURLOPT_COOKIEJAR, "/tmp/cookies.txt");
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1 );
curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 30 );
curl_setopt( $ch, CURLOPT_TIMEOUT, 30 );
curl_setopt( $ch, CURLOPT_HEADER, 0);
curl_setopt( $ch, CURLOPT_REFERER, "http://www.gmail.com");
curl_setopt( $ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/3.5.0.1");
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
$page = curl_exec( $ch );
$info = curl_getinfo($ch);
$info returns :
[url] => MASKED
[content_type] =>
[http_code] => 0
[header_size] => 0
[request_size] => 0
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0
[namelookup_time] => 0
[connect_time] => 0
[pretransfer_time] => 0
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => -1
[upload_content_length] => -1
[starttransfer_time] => 0
[redirect_time] => 0
I installed on the server regular cURL.
So if I do
curl domain.com
It works !!
It's the same domain.
I tried clearing up the firewall, and also having cURL use FRESH_CONNECT so it pulls the latest IP for the domain.
Still a no go. Ideas ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的服务器IP可能被屏蔽了。
您是否尝试过:
那么引荐来源网址是实际的域?
您能给我域名以便我测试问题吗?
The ip of your server could be blocked.
Did you try :
So the referrer is the actual domain ?
Could you give me the domain name so I could test the problem?