Connecting to server from a different IP using API


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

$url = ''; 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?