Migration to OAuth 2.0 + HTTPS and Upgrade to Facebook’s PHP SDK v3.0.0

As Facebook’s new roadmap all Facebook app have to have HTTPS or SSL certificate. Facebook also updated their sdk to meet the changes they will do. Here i will show how easily you can use their new sdk.

First download the new sdk. now If you’re currently using the PHP SDK (v2.2.x) for authentication, you will recall that the login code looked like this:

$facebook = new Facebook(...);
$session = $facebook->getSession();
if ($session) {
  // proceed knowing you have a valid user session
} else {
  // proceed knowing you require user login and/or authentication
}

Now you check login using this code.

$facebook = new Facebook(…);
$user = $facebook->getUser();
if ($user) {
  // proceed knowing you have a logged in user who's authenticated
} else {
  // proceed knowing you require user login and/or authentication
}

So all you have to do is to check the $user variable to check the user is authenticated or not. All other api calls are the same as previous.

About Zakir Hyder

This entry was written by .

21. May 2011 by Zakir Hyder
Categories: Facebook, Graph Api, PHP, Social Networking Application Development | Tags: , , , , , | Comments

Comments

  1. […] Migration to OAuth 2.0 + HTTPS and Upgrade to Facebook’s PHP SDK v3.0.0 Saturday, May 21, 2011 2:34 PM […]