I am implementing a relative PHP Newbiz a PayPal IPN listener and all are working fine, I do not know To know exactly how to check a response code.
I have tried something ugly with curls but it does not work at all (I do not understand curl).
I have tried this piece of code that I caught from somewhere on the net:
$ fp = fsockopen ('ssl: //www.sandbox.paypal .com ', 443, $ wrong, $ errstr, 30); $ Response_headers = get_headers ($ fp); $ Response_code = (int) substr ($ response_headers [0], 9, 3);
... but this does not work (returns $ response_code = 0).
So now, I'm debugging my IPN code without checking for a response 200
thanks
this is get_headers ( $ url ), do not get_headers ($ fp) until I get it completely wrong Reading (and I have never seen such a thing), you have to pass the URL you are reading, not handle the socket. In fact, this apparently does its GET, so it will be useless for your current work.
fsockopen (...) is a lower level (TCP / IP) function. This gives a socket handle, does not handle curls, this is the reason why you can not use curl_getinfo (...) on it. You want something like this ...
$ fp = Curl_init ('https://www.sandbox.paypal.com/cgi-bin/webscr'); Curl_setopt ($ FP, CURLOPT_POST, true); Curl_setopt ($ FP, CURLOPT_POSTFIELDS, $ _POST); Curl_setopt ($ fp, CURLOPT_RETURNTRANSFER, true); $ Response = curl_xac ($ fp); $ Response_code = curl_getinfo ($ fp, CURLINFO_HTTP_CODE); I remember excepting
, you need to add 'CMD = _Notify-validate' to post areas.
Do not use FSOcopes (...). Yes, I know what the PayPal sample code does but it needs to be run everywhere, and you can use it if you have curl set.
Comments
Post a Comment