douza1373 2016-07-28 23:08
浏览 66
已采纳

我将它上传到我的服务器后,Php curl不起作用

It seems that curl works on my localhost but when I upload it to my server it stops working.

This is when i have it on localhost : enter image description here And this is on the host provider server : enter image description here

I am not a professional developer but i think there can be a problem with the host provider one.com

<?php
require 'kint/Kint.class.php';
$cURL = curl_init('162.243.44.4/server_list.json');
curl_setopt($cURL, CURLOPT_PORT, 3000);
curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true);

$jsondata = curl_exec($cURL);
Kint::dump($jsondata);
$json = json_decode($jsondata, true);



function ping($host,$port=4000,$timeout=6)
    {
        $fsock = fsockopen($host, $port, $errno, $errstr, $timeout);
        if ( ! $fsock )
        {
            return 'Offline';
        }
        else
        {
            return 'Online';
        }
    }

    Kint::dump($json['servers']);
    foreach ($json['servers'] as $js){
        echo  $js['name'] . ' is ' . ping($js['ip']) . ' <br>';
    }
?>
  • 写回答

1条回答 默认 最新

  • duanquan1243 2016-07-29 00:29
    关注

    I think I found the problem, it seems to work on c9.io so it's something to do with one.com, in future I will only buy real servers instead of a cheap host provider.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!