socialmedia_oauth_connect::Authorize PHP Method

Authorize() public method

public Authorize ( )
    public function Authorize()
    {
        if ($this->oauth_version == "2.0") {
            $dialog_url = $this->dialogUrl . "client_id=" . $this->client_id . "&response_type=" . $this->responseType . "&scope=" . $this->scope . "&state=" . $this->state . "&redirect_uri=" . urlencode($this->redirect_uri);
            echo "<script> top.location.href='" . $dialog_url . "'</script>";
        } else {
            $date = new DateTime();
            $request_url = $this->requestUrl;
            $postvals = "oauth_consumer_key=" . $this->client_id . "&oauth_signature_method=HMAC-SHA1" . "&oauth_timestamp=" . $date->getTimestamp() . "&oauth_nonce=" . $this->nonce . "&oauth_callback=" . $this->redirect_uri . "&oauth_signature=" . $this->client_secret . "&oauth_version=1.0";
            $redirect_url = $request_url . "" . $postvals;
            $oauth_redirect_value = $this->curl_request($redirect_url, 'GET', '');
            $dialog_url = $this->dialogUrl . $oauth_redirect_value;
            echo "<script> top.location.href='" . $dialog_url . "'</script>";
        }
    }

Usage Example

	@History		:	V1.0 - Released oauth 2.0 service providers login access	
	@oauth2		:	Support following oauth2 login
					Bitly
					Wordpress
					Paypal
					Facebook
					Google
					Microsoft(MSN,Live,Hotmail)
					Foursquare
					Box
					Reddit
					Yammer
					Yandex					
*/
include "socialmedia_oauth_connect.php";
$oauth = new socialmedia_oauth_connect();
$oauth->provider = "Facebook";
$oauth->client_id = "482962811753376";
$oauth->client_secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$oauth->scope = "email,publish_stream,status_update,friends_online_presence,user_birthday,user_location,user_work_history";
$oauth->redirect_uri = "http://ngiriraj.com/socialMedia/oauthlogin/facebook.php";
$oauth->Initialize();
$code = $_REQUEST["code"] ? $_REQUEST["code"] : "";
if (empty($code)) {
    $oauth->Authorize();
} else {
    $oauth->code = $code;
    #	print $oauth->getAccessToken();
    $getData = json_decode($oauth->getUserProfile());
    $oauth->debugJson($getData);
}