Monday, April 18, 2011

CURL POSTING ISSUES

In case of, developing a Facebook App, we need to first download the FB Class file (get the download links here- http://developers.facebook.com/docs/sdks/ or from here- https://github.com/facebook/php-sdk/) and need to do all work with its member functions. The First common issue is getting CURL exceptions while Posting in the wall. We can track the CURL error and fix that issue. There is another issue regarding CURL SSL certificate. We can simply turn off the CURL SSL Varifier. Here are the code changes- 1. Download PHP SDK from- https://github.com/facebook/php-sdk/ 2. We need to turn-off the SSL Varification Search for the array-
public static $CURL_OPTS = array(
and add another variable/ CURL-Property into it-
CURLOPT_SSL_VERIFYPEER => false
So, Finally the block will look like-
public static $CURL_OPTS = array(
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 60,
CURLOPT_USERAGENT => 'facebook-php-2.0',
CURLOPT_SSL_VERIFYPEER => false
);
3. For the CURL Error 77 (common while Posting through IE) Search for this line-
if (curl_errno($ch) == 60) { // CURLE_SSL_CACERT
and simply modify this to-
if (curl_errno($ch) == 60 || curl_errno($ch) == 77) { // CURLE_SSL_CACERT
- it will escape the 77 Error as well. - and we are done.

No comments:

Post a Comment