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

我将它上传到我的服务器后,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.

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

报告相同问题?

悬赏问题

  • ¥30 Hyper-v虚拟机相关问题,求解答。
  • ¥15 TSM320F2808PZA芯片 Bootloader
  • ¥45 谷歌浏览器出现开发者工具无法显示已创建的,但您可以调试已部署的代码。 状态代码 404, net::ERR HTTP RESPONSE CODE FAILURE
  • ¥15 chatgpt网页版侧边栏和模型切换点击没反应怎么办
  • ¥15 如何解决蓝牙通话音频突发失真问题
  • ¥15 安装opengauss数据库报错
  • ¥15 【急】在线问答CNC雕刻机的电子电路与编程
  • ¥60 在mc68335芯片上移植ucos ii 的成功工程文件
  • ¥15 笔记本外接显示器正常,但是笔记本屏幕黑屏
  • ¥15 Python pandas