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 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器