Facebook Graph API PHP-SDK Fork

by Matt Mecham on June 7, 2010

in Uncategorized

As you are no doubt aware, recently Facebook unveiled a new suite of APIs that we can use in our own applications. IP.Board already had existing integration via Facebook Connect but we decided to move over to the new Graph APIs for IP.Board 3.1 and be right on the curve.

As IP.Board is used on thousands of different hosting machines, we are used to making our code as portable as possible. This usually means ensuring there is fallback functionality for common PHP extensions.

The official PHP SDK is at github.com. It’s very early days so it hasn’t fully matured. It has no fallback methods when CURL isn’t available which is more common that you think. It also has a small bug with the CURL methods for Windows machines (IIS). None of these are huge problems but we had to fix them as we had no control over the hosting environments used.

Rather than manually patch the files, I simply forked the project so I can merge it with the official distribution for our own use. I also issued a pull request. Hopefully the Facebook developers will integrate the changes into their core code.

Until they do, you are welcome to use my Facebook PHP SDK github fork which fixes the following issues:

- Socket POST fallback for when CURL isn’t available
- SSL_VERIFYPEER fix for IIS hosting environements
- ‘curl_setop_array’ check for PHP < 5.1.3

Github.com was an excellent choice for hosting their source code, and I congratulate them for making it so easy to fork and fix.

Also, please note that I am maintaining this fork personally, not Invision Power Services.

{ 11 comments… read them below or add one }

1 Martin Sikora June 23, 2010 at 9:13 am

Hi,
thanks for your modified Facebook API. It helped me a lot!
I was just thinking maybe it would be a good idea to try to use non-Curl way when the standard Curl throws an exception. That was for instance my issue. I left a comment here http://github.com/facebook/php-sdk/issues/#issue/121

have a nice day,
Martin :)

2 Matt M June 23, 2010 at 9:48 am

Hi Martin,

Thanks for the comments. I have updated the facebook.php file to fix the CURL error 77 issue you were having.

3 Anthony August 13, 2010 at 12:32 am

Thank you very much for the 77 error, your fork worked great for me !

Regards,
Anthony

4 meee September 4, 2010 at 7:17 pm

fsockopen() [function.fsockopen]: unable to connect to ssl://api-read.facebook.com:443 (Unable to find the socket transport “ssl” – did you forget to enable it when you configured PHP?)

5 meee September 8, 2010 at 10:16 am

I can’t use it on my server ?

6 Phuong September 14, 2010 at 9:19 am

I have a problem. There is a CurlException when I call the function $facebook->api(‘me’);
[message] => Couldn’t resolve host ‘graph.facebook.com’
Could anyone help me, please ?

7 admin September 14, 2010 at 9:31 am

I see that now and again. If you have access, check your etc/hosts file. If you do not have access or everything seems in order, I’d deliberately sabotage the script to force it to bypass CURL and use the POST fallback. I need to update the fork to keep up with recent Facebook API changes. I’ll add a constant in to easily disable CURL for this reason.

8 Шишкин November 30, 2010 at 9:41 am

Привет ребят подскажите как интегрировать код на phpbb3?

9 abhishek December 1, 2010 at 8:59 am

when i pressed connect with facebook button
i redirected to facebo0k login page
after successful loging i redirected to ur example.php page
but message gives “session you are not connected” why?
please rectify this urgently

10 Marzia January 23, 2011 at 9:16 pm

I adore you boy!!! you save me a lot of headache! Thanks

11 Binh Nguyen May 24, 2012 at 11:38 am

below solution helpfull for me :Đ

Facebook::$CURL_OPTS[CURLOPT_SSL_VERIFYPEER] = false;
Facebook::$CURL_OPTS[CURLOPT_SSL_VERIFYHOST] = 2;

hope can help u

Leave a Comment

Connect with Facebook

Previous post:

Next post: