HTML and CSS Reference
* Loads the user's data from the Facebook Graph API
* @return void
protected function load_user_data( )
. 'access_token=' . $this->access_token;
$response = $this->request_uri($graph_uri);
// Decode the response and store the values in the object
$user = json_decode($response);
$this->id = $user->id;
$this->name = $user->name;
$this->username = $user->username;
$this->email = $user->email;
* Generates HTML markup to display the user's Facebook profile image
* @return void
protected function load_user_profile_image( )
$this->profile_image = '<img src="' . $image_path . '" '
. 'alt="' . $this->name . '" />';
First, because Facebook sends back data in JSOn-encoded format, the script will throw an Exception if the json
extension isn't loaded in php.
After that, the RWA_Facebook class is declared to extend RWA_OAuth . inside, two properties are redeclared—
$service_auth_endpoint and $service_token_endpoint —the constructor is redefined, and the two abstract
methods from RWA_OAuth are declared.
$service_auth_endpoint and $service_token_endpoint are Facebook-specific, and as such they can be
hard-coded into the class.
Other property values—namely, $client_auth_endpoint , $client_id , $client_secret , and, optionally, $scope
(if we require more than basic application, which we don't)—are set via the constructor. the endpoint and app
credentials are required, throwing an Exception if they're not set, and after that the method checks for scope in
the $config array. then the parent constructor is run to check for login and logout attempts.