Solving Uncaught CurlException: name lookup timed out in facebook.php
If you are facebook developer, and are using the latest facebook php sdk, facebook.php grabbed from github.com, and are facing the problem similiar to as defined below:
PHP Fatal error: Uncaught CurlException: 6: name lookup timed out thrown in /<location>/facebook.php on line 592
This is probably the host is not given enough time to contact with facebook server. To solve this problem, open facebook.php with your editor, and go to line 89 to find the code below:
public static $CURL_OPTS = array( CURLOPT_CONNECTTIMEOUT => 10, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 60, CURLOPT_USERAGENT => 'facebook-php-2.0', );
Modify CURLOPT_CONNECTION to increase its value to, 30 or higher.
CURLOPT_CONNECTTIMEOUT => 30,
and test your facebook application again to see if it works.
Suggestion: Change to a better host to resolve the problem without modifying the facebook.php script
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