Connecting to server from a different IP using API

1 post / 0 new
#1 Mon, 04/25/2016 - 21:50
hinhthoi

Connecting to server from a different IP using API

Hi,

I can communicate with the server using the following PHP script if the PHP script is executed from the server

$url = 'https://63.142.249.131:10000/virtual-server/remote.cgi?program=list-commands&json=1';
echo testconnection($url);

function testconnection($url) {
$ch = curl_init();
//curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_USERPWD, "root:pass");
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt ($ch, CURLOPT_URL, $url);
        curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
$result = curl_exec ($ch);
curl_close ($ch);
return $result;
}

The exact same script, if it is executed from another webserver (with php curl installed), it doesn't connect.

Could anyone help me how to connect from a different server?

Thanks!