PHP CURL
Posted: Fri May 08, 2009 4:19 pm
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.
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);
?>