3

我在我的本地主机上测试脚本,它运行良好。我在我的实时服务器上试过,但它没有用。

<?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
    )

不确定url的端口是否是问题所在。我尝试搜索以解决问题,但没有运气。

4

1 回答 1

3

来自评论:

您的虚拟主机可能会阻止端口 8090 上的出站流量。许多虚拟主机会阻止不常见的端口以增加安全性。解决此问题的唯一方法是联系您的虚拟主机并要求他们取消阻止端口,以便您可以连接它。

于 2013-09-14T02:03:41.590 回答