I am trying to write a web services application based on the REST theory. I am doing what is outlined at: http://www.onlamp.com/pub/a/php/2003/10/30/amazon_rest.html Basically what I want to do is go to a url, grab the xml that is at that url and store it into a variable so I can do an xslt transformation on it later with another variable.
I am having problems with the following lines of code:
$c = curl_init($url);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
//curl_exec($c);
$xml = curl_exec($c);
if (curl_error($c)) {
printf("Error %s: %s", curl_errno($c), curl_error($c));
}
curl_close ($c);
when the code runs, I get:
Error 7: Connect failed
I can go to the url in a web browser with no problem, but can't get it using this code.
I've also tried
file_get_contents($url);
and I get:
failed to open stream: Bad file descriptor in (file name, line number ...)
I've searched php.net, and phpbuilder, but as far as I can tell, my code is right. I am working behind a proxy and firewall (I'm about to take my code home and see if it works there!) I thought maybe this might have some impact, I've come across
curl_setopt ($c, CURLOPT_PROXY, $proxy);
with $proxy being set to my proxy (both IP address and dns name), didn't make any difference!
If anyone has any suggestions, I would be very greatful.