The Facebook PHP SDK is composed of two files: facebook.php and base_facebook.php. The first includes the definition for the Facebook class. The second includes the definition for the BaseFacebook class, which is a parent class for Facebook together with few more classes.
You can easily download the Facebook PHP SDK at https://github.com/facebook/facebook-php-sdk. The following video clip shows that.
The following code is of a simple facebook application that if the user still hasn’t installed it he is taken through a series of screens in order to install it. Make sure you use your application id and your application secret code.
<?php require_once('facebook.php'); $facebook = new Facebook(array( 'appId' => 'APP_ID', 'secret' => 'APP_SECRET', 'cookie' => true)); $user = $facebook->getUser(); $login_url = $facebook->getLoginUrl( array( 'redirect_uri' => 'https://apps.facebook.com/yoyogagala', 'scope' => 'email,offline_access,publish_stream,user_birthday,user_location,user_work_history,user_about_me,user_hometown') ); $logout_url = $facebook->getLogoutUrl(); if ($user) { echo "<h1>logged in</h1>"; $user_profile = $facebook->api('/me'); var_dump($user_profile); } else if (!$user) { echo "<script type='text/javascript'>top.location.href = '$login_url';</script>"; } ?>
The following video clip overviews this code sample and shows its execution. If you are not familiar with facebook applications development I strongly recommend to follow it.
The following video clips show simple code samples for interacting with the Facebook Graph API. The following video clip shows how to get detailed information about the current user.
The following video clip shows how to get detailed information about the friends of the current user.
The following video clip shows how to get detailed information about the likes of the current user.
The following video clip shows how to get detailed information about the photos of the current user. Make sure the required permission was specified.
The following video clip shows how to post a new message on the current user’s wall. Make sure the required permission was specified.