Using the PayPal IPN, I keep getting an error 400.
I have been making the script send me emails of $res to see what the response is, inside of the
$res
Since you're opening the socket yourself, rather than using an HTTP library such as curl, you need to set the proper HTTP Protocol version and add the HTTP Host header yourself just below the POST line.
$header = "POST /cgi-bin/webscr HTTP/1.1\r\n"; $header .= "Host: www.sandbox.paypal.com\r\n";