Liberty Reserve – XML API with SSL error fix
Back to few days ago, Liberty Reserve (LR) XML API is not working in my PHP script, when I try to retrieve the transaction history. If you do not know what is LR, it is one of the largest E-currency payment gateway.
I have been using CURL to retrieve the information for since few months ago. By using curl_error function, PHP output the following error:
SSL read: error:00000000:lib(0):func(0):reason(0), errno 104
It seem like is the SSL is causing the problem. Ignoring the CURL, I use file_get_contents to fetch the URL information without luck. However, the information can be retrieved if I paste the long XML encoded URL directly into the browser. By doing some research on Google on SSL with CURL, finally I fixed the problem with my own.
The solution is just to add another line of code curl_setopt if you have not done so:
// $ch - initialized CURL resource curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"
Normally user agent is set if the site allow legit browser only. Not sure why LR is changing this all of sudden, but at least the fix is working for me.
Like