HTML and CSS Reference
In-Depth Information
public function logout( )
$this->logged_in = FALSE;
$this->access_token = FALSE;
public function get_login_uri( ) {...}
protected function get_access_token_uri( ) {...}
protected function save_access_token( ) {...}
protected function request_uri( ) {...}
abstract protected function load_user_data();
abstract protected function load_user_profile_image();
the is_logged_in() method is the simplest of the bunch, simply returning the value of $logged_in .
logout() is also pretty simple: it sets $logged_in and $access_token to FALSE , makes sure the access token is
removed from the session, and then destroys the session altogether.
check_login() looks for state and code in the query string, and if they're present it checks that the state
matches the one stored in the session. if they match, the save_access_token() method is run; then the two
abstract methods from the class are called ( load_user_data() and load_user_profile_image() , which will be
defined in a child class). if they don't match, an Exception is thrown.
if the user is not logged in, but an access token is present in the session, the script will save the access token in
the object, set $logged_in to TRUE , and load the user data and profile image.
the constructor for the object checks first for a logout attempt, which is sent via the query string
( $_GET['logout'] ). Barring that, it runs check_login() .
Step 3: Build the Facebook OAuth Child Class
With the RWA_OAuth class in place, we can work on a service-specific OAuth implementation. For this example,
we'll use Facebook.
in the includes folder, create a new file called . inside, place the following code:
// Makes sure JSON can be parsed
if (!extension_loaded('json')) {
throw new Exception('OAuth requires the JSON PHP extension.');
Search WWH ::

Custom Search