HTML and CSS Reference
In-Depth Information
The Rest of the Class Methods
Let's wrap up the RWA_OAuth class by defining the remaining four methods:
abstract class RWA_OAuth
{
public $service_auth_endpoint, $service_token_endpoint, $scope,
$client_id, $client_secret, $client_auth_endpoint,
$id, $username, $name, $email, $profile_image;
protected $logged_in = FALSE,
$access_token = FALSE;
public function __construct( )
{
if (isset($_GET['logout']) && $_GET['logout']==1) {
$this->logout();
header('Location: ' . $this->client_auth_endpoint);
exit;
}
$this->check_login();
}
public function check_login( )
{
if (isset($_GET['state']) && isset($_GET['code'])) {
if ($_GET['state']===$_SESSION['state']) {
$this->save_access_token();
$this->load_user_data();
$this->load_user_profile_image();
} else {
throw new Exception("States don't match.");
}
} elseif (!$this->logged_in && !$this->access_token) {
if (isset($_SESSION['access_token'])) {
$this->access_token = $_SESSION['access_token'];
$this->logged_in = TRUE;
$this->load_user_data();
$this->load_user_profile_image();
}
}
}
public function is_logged_in( )
{
return $this->logged_in;
}
 
Search WWH ::




Custom Search