I am having a problem with PHP's curl. So I have a file on an ubuntu server that is called:
example.php
this file has the following code:
<?php
$url = "some url that returns xml";
$curl = @curl_init ($url);
@curl_setopt ($curl, CURLOPT_HEADER, FALSE);
@curl_setopt ($curl, CURLOPT_RETURNTRANSFER, TRUE);
@curl_setopt ($curl, CURLOPT_FOLLOWLOCATION, TRUE);
@curl_setopt ($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
$source = @curl_exec ($curl);
@curl_close ($curl);
print $source;
?>
(of course the URL is real, you could try any URL that returns xml).
Now, this works if I call it from the server that the file is one, however, it doesn't work if I run it from a different server by calling that server's IP.
I thought it is a problem with the firewall, however, if you add the line:
print "something to test";
on top of the
$curl = @curl_init ($url);
statement, it will print that statement only which means that servers are talking to each other. Is there any setting that does not allow curl output or something like that, I am not sure what the problem could be. Any hints, are appreciated :)
Also, we know that the URL returns xml code fine because when you run the script on the server it is on, it runs perfectly fine which means the url (sorry for not being to post it here) is fine and the script also is fine, it is just connection between the two servers in that particular case is not working and i am not sure what's going on.
(One last thing to add: the status of the request returns 200 (OK) it just that the response is empty while it should include the xml code, which it does include when you call file from the server it is actually on).