Php Curl 实时服务器不工作 [英] Php Curl live server not working

查看:32
本文介绍了Php Curl 实时服务器不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

'xxxxxxxxxxxxxxxxxxx'));curl_setopt($ch, CURLOPT_PORT, '8090');curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);$postResult = curl_exec($ch);$response = curl_getinfo($ch);echo "

";打印_r($响应);echo "</pre>";curl_close($ch);echo "

";打印_r($postResult);//file_put_contents(dirname(__FILE__).'/xml_record/live.xml', $postResult);?>

本地主机我打印_r curl_getinfo($ch).

数组([网址] =>http://remote.xxxxxxxx.com.au:8090/Options.API[内容类型] =>文本/html;字符集=utf-8[http_code] =>200[header_size] =>246[请求大小] =>215[文件时间] =>-1[ssl_verify_result] =>0[redirect_count] =>0[总时间] =>2.278[名称查找时间] =>0[连接时间] =>0.344[预传输时间] =>0.344[下载内容长度] =>9376[上传内容长度] =>759[开始传输时间] =>0.734[重定向时间] =>0[证书信息] =>大批()[redirect_url] =>)

现场测试我打印_r curl_getinfo($ch).

 数组([网址] =>http://remote.xxxxxxxxxxx.com.au:8090/Options.API[内容类型] =>[http_code] =>0[header_size] =>0[请求大小] =>0[文件时间] =>-1[ssl_verify_result] =>0[redirect_count] =>0[总时间] =>0.012024[名称查找时间] =>0.011809[连接时间] =>0[预传输时间] =>0[下载内容长度] =>-1[上传内容长度] =>-1[开始传输时间] =>0[重定向时间] =>0)

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

解决方案

来自评论:

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

I test the script on my localhost and it working perfectly. I tried on my the live server and it didn't work.

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

?>

Localhost I print_r the 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] => 
)

Live test I print_r the 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
    )

Not sure if the port of the url is the problem. I try to search to solve the problem but no luck.

解决方案

From Comments:

Your webhost is probably blocking outbound traffic on port 8090. Many webhosts block uncommon ports for added security. The only way to get this resolved is to contact your webhost and ask them to unblock the port so that you can connect on it.

这篇关于Php Curl 实时服务器不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆