PHP - CURL - 连接被拒绝
PHP - CURL - Connection refused
我正在尝试连接到远程服务:
function test(){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://myhost.ddns.net/myfile.cgi');
curl_setopt($ch, CURLOPT_USERPWD, "user:password");
curl_setopt($ch, CURLOPT_PORT, 10000);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
if(curl_exec($ch) === false)
{
echo 'Curl error: ' . curl_error($ch).'<br>';
$info = curl_getinfo($ch);
print_r($info);
}
else
{
echo 'Operation completed without any errors';
}
// Close handle
curl_close($ch);
}
但我总是得到这样的输出:
Curl error: Failed to connect to myhost.ddns.net port 10000: Connection refused
Array
(
[url] => http://myhost.ddns.net/myfile.cgi
[content_type] =>
[http_code] => 0
[header_size] => 0
[request_size] => 0
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.261142
[namelookup_time] => 0.060601
[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
[redirect_url] =>
[primary_ip] =>
[certinfo] => Array
(
)
[primary_port] => 0
[local_ip] =>
[local_port] => 0
)
如果我尝试在浏览器上访问 http://myhost.ddns.net:10000/myfile.cgi,系统会提示我输入 user/pass 身份验证和 200 代码。只是 CURL 不工作...
有什么想法吗?
最后我的主机阻塞了 10000 端口。我要求解除阻塞,现在可以了。
谢谢大家。
我正在尝试连接到远程服务:
function test(){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://myhost.ddns.net/myfile.cgi');
curl_setopt($ch, CURLOPT_USERPWD, "user:password");
curl_setopt($ch, CURLOPT_PORT, 10000);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
if(curl_exec($ch) === false)
{
echo 'Curl error: ' . curl_error($ch).'<br>';
$info = curl_getinfo($ch);
print_r($info);
}
else
{
echo 'Operation completed without any errors';
}
// Close handle
curl_close($ch);
}
但我总是得到这样的输出:
Curl error: Failed to connect to myhost.ddns.net port 10000: Connection refused Array ( [url] => http://myhost.ddns.net/myfile.cgi [content_type] => [http_code] => 0 [header_size] => 0 [request_size] => 0 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.261142 [namelookup_time] => 0.060601 [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 [redirect_url] => [primary_ip] => [certinfo] => Array ( ) [primary_port] => 0 [local_ip] => [local_port] => 0 )
如果我尝试在浏览器上访问 http://myhost.ddns.net:10000/myfile.cgi,系统会提示我输入 user/pass 身份验证和 200 代码。只是 CURL 不工作...
有什么想法吗?
最后我的主机阻塞了 10000 端口。我要求解除阻塞,现在可以了。
谢谢大家。