Page 1 of 1

PHP CURL

Posted: Fri May 08, 2009 4:19 pm
by shanecody
This is the first time i have worked with curl.

I have written the below code to access a program using REST, and am getting the error "couldn't connect to host".

Can someone look at it and see if it is something wrong with the code.

Code: Select all

 
<?php
function sendRequest($url, $user, $pass)
{   
    $ch = curl_init();
    
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_PORT, 10090);
    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
  curl_setopt($ch, CURLOPT_USERPWD, "$user:$pass");
    curl_setopt($ch, CURLOPT_HEADER, 0);
    
    // grab URL and pass it to the browser
    curl_exec($ch);
    echo curl_error($ch);
    
    // close cURL resource, and free up system resources
    curl_close($ch);
 
}
 
$urlRegions = "http://76.76.241.110:10090/rexwapi/common/regions";
$user = "rex-rex";
$pass = "rex-4-rex";
 
sendRequest($urlRegions, $user, $pass);
?>
 

Re: PHP CURL

Posted: Fri May 08, 2009 4:50 pm
by requinix
Works for me.

Can you ping 76.76.241.110 from your server?

Re: PHP CURL

Posted: Fri May 08, 2009 5:55 pm
by shanecody
no i cannot

Re: PHP CURL

Posted: Fri May 08, 2009 6:23 pm
by requinix
Oh, seems to be blocking pings.

Try telnetting to it on that port.

Code: Select all

$ telnet 76.76.241.110 10090
If you don't get an error message then it probably worked.

Re: PHP CURL

Posted: Sun May 10, 2009 3:09 pm
by shanecody
Thank you, it was the server firewall blocking the request out.