我在本地主机上测试脚本,它运行正常。我在我的实时服务器上试了一下它没有用。
<?php
$uploadfile=dirname(__FILE__)."/xml_request/cat.xml";
$ch = curl_init("http://remote.xxxxxxxxxx.com.au:8090/Options.API");
curl_setopt($ch, CURLOPT_POSTFIELDS,
array('Request'=>"@$uploadfile",
'clientKey'=>'xxxxxxxxxxxxxxxxxxx'));
curl_setopt($ch, CURLOPT_PORT, '8090');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$postResult = curl_exec($ch);
$response = curl_getinfo($ch);
echo "<pre>";
print_r($response);
echo "</pre>";
curl_close($ch);
echo "<pre>";
print_r($postResult);
//file_put_contents(dirname(__FILE__).'/xml_record/live.xml', $postResult);
?>
本地主机 我print_r curl_getinfo($ ch)。
Array
(
[url] => http://remote.xxxxxxxx.com.au:8090/Options.API
[content_type] => text/html; charset=utf-8
[http_code] => 200
[header_size] => 246
[request_size] => 215
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 2.278
[namelookup_time] => 0
[connect_time] => 0.344
[pretransfer_time] => 0.344
[download_content_length] => 9376
[upload_content_length] => 759
[starttransfer_time] => 0.734
[redirect_time] => 0
[certinfo] => Array
(
)
[redirect_url] =>
)
现场测试 我print_r curl_getinfo($ ch)。
Array
(
[url] => http://remote.xxxxxxxxxxx.com.au:8090/Options.API
[content_type] =>
[http_code] => 0
[header_size] => 0
[request_size] => 0
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.012024
[namelookup_time] => 0.011809
[connect_time] => 0
[pretransfer_time] => 0
[download_content_length] => -1
[upload_content_length] => -1
[starttransfer_time] => 0
[redirect_time] => 0
)
不确定网址的端口是否有问题。我试着搜索解决问题,但没有运气。
答案 0 :(得分:1)
来自评论:
您的webhost可能阻止端口8090上的出站流量。许多虚拟主机阻止不常见的端口以增加安全性。解决此问题的唯一方法是联系您的虚拟主机并要求他们取消阻止端口,以便您可以连接它。