0

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>';
    }
?>
Ivan Barayev
  • 2,035
  • 5
  • 24
  • 30
Hajar Rashidi
  • 79
  • 2
  • 11
  • 1
    Is the php curl module installed on the host? – Jaime Jul 28 '16 at 23:11
  • Check if the curl module is installed and supported to see if that's the issue http://stackoverflow.com/questions/13433946/how-to-check-if-curl-is-enabled-or-disabled – robobobobo Jul 28 '16 at 23:14
  • It says it is installed, look at this link http://hazar.se/sv/ – Hajar Rashidi Jul 28 '16 at 23:22
  • there's a lot of useful info curl will return if you just ask it to –  Jul 28 '16 at 23:23
  • I did PHP info() and this is what I get back, as I said I am a noob at this, I don't know what these things mean. here is the info I get back http://imgur.com/a/rWMAE – Hajar Rashidi Jul 28 '16 at 23:28
  • Your problem isn't with curl, it's with $json['servers']. Add var_dump($json) above foreach and post the output. – Ben Shoval Jul 28 '16 at 23:32
  • Ben that's not the problem because $jsondata is false (which means it don't work). I listen to you and did a var_dump, the result was NULL, the problem happens at $jsondata when i var_dump it i get $jsondata bool FALSE – Hajar Rashidi Jul 28 '16 at 23:41

1 Answers1

0

My host provider didn't have cURL activated at their current php version

Hajar Rashidi
  • 79
  • 2
  • 11
  • One.com support: Michael: Yes cURL is supported, but be aware that if anything else other than port 80 and 443 (for https/ssl) is used, our firewall will most likely block it. – Hajar Rashidi Jul 29 '16 at 00:38