[Edit]
I have reedited the previous question - since I had misunderstood what was causing the problem - and therefore the ample snippet I had before was a red herring. Thanks to wimdvx, I have a clearer idea as to what is going on.
First of all, I am using code that is base on this one, to handle IPN notifications from Paypal.
I was unable to connect using fsockopen, so I wrote a small snippet (shown below), to try to connect to Paypal.
<?php
$fp = fsockopen("www.sandbox.paypal.com/cgi-bin/webscr", 80, $errno, $errstr,30);
if(!$fp) {
echo "$errstr ($errno)<br />\n";
}
else{
$out = "GET / HTTP/1.1\r\n";
$out .= "Host: www.sandbox.paypal.com/cgi-bin/webscr\r\n";
$out .= "Connection: Close\r\n\n\n";
fwrite($fp, $out);
}
?>
When I run this little script, I get the following error on my server:
PHP Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/minime/test-socket.php on line 2 PHP Warning: fsockopen(): unable to connect to www.sandbox.paypal.com/cgi-bin/webscr:80 (php_network_getaddresses: getaddrinfo failed: Name or service not known) in /home/minime/test-socket.php on line 2 php_network_getaddresses: getaddrinfo failed: Name or service not
known (0)
Can anyone shed some light on how to fix this?
I am running Ubuntu 10.0.4 LTS on the server