示例#1
0
	public function GetAccessToken($redirect_uri)
	{
		if($this->code === false)
			return false;

		$result = CHTTP::sPost(self::TOKEN_URL, array(
			"code"=>$this->code,
			"client_id"=>$this->appID,
			"client_secret"=>$this->appSecret,
			"redirect_uri"=>$redirect_uri,
			"grant_type"=>"authorization_code",
		));

		$arResult = CUtil::JsObjectToPhp($result);

		if(isset($arResult["access_token"]) && $arResult["access_token"] <> '')
		{
			$this->access_token = $arResult["access_token"];
			$_SESSION["OAUTH_DATA"] = array("OATOKEN" => $this->access_token);
			return true;
		}
		return false;
	}
示例#2
0
 	public function GetAccessToken()
 	{
 		if(!$this->token || !$this->tokenVerifier || !$this->tokenSecret)
 			return false;
 			
 		$arParams = array_merge($this->GetDefParams(), array(
			"oauth_token" => $this->token,
			"oauth_verifier" => $this->tokenVerifier,
		));

		$arParams["oauth_signature"] = $this->BuildSignature($this->GetSignatureString($arParams, self::TOKEN_URL));

		$result = CHTTP::sPost(self::TOKEN_URL, $arParams);
		parse_str($result, $arResult);
		if(isset($arResult["oauth_token"]) && $arResult["oauth_token"] <> '')
		{
			$this->token = $arResult["oauth_token"];
			$this->tokenSecret = $arResult["oauth_token_secret"];
			return $arResult;
		}
		return false;
 	}
示例#3
0
 public function Validate()
 {
     if (CSocServAuthManager::CheckUniqueKey()) {
         if ($arOpenidServerTags = $this->GetOpenIDServerTags($_GET['openid_identity'])) {
             $arParams = array('openid.assoc_handle' => $_GET['openid_assoc_handle'], 'openid.signed' => $_GET['openid_signed'], 'openid.sig' => $_GET['openid_sig']);
             $arSigned = explode(',', $_GET['openid_signed']);
             foreach ($arSigned as $s) {
                 $arParams['openid.' . $s] = $_GET['openid_' . str_replace('.', '_', $s)];
             }
             $arParams['openid.mode'] = 'check_authentication';
             if (isset($_SESSION['BX_OPENID_RETURN_TO'])) {
                 $arParams['openid.return_to'] = $_SESSION['BX_OPENID_RETURN_TO'];
                 unset($_SESSION['BX_OPENID_RETURN_TO']);
             }
             $str = CHTTP::sPost($arOpenidServerTags['server'], $arParams, true);
             if (preg_match('/is_valid\\s*\\:\\s*/' . BX_UTF_PCRE_MODIFIER, $str)) {
                 return array('server' => $arOpenidServerTags['server'], 'identity' => $_GET['openid_identity']);
             } else {
                 $GLOBALS['APPLICATION']->ThrowException(GetMessage('OPENID_CLIENT_ERROR_AUTH'));
             }
         }
     }
     //	self::CleanParam('ERROR');
     $GLOBALS['APPLICATION']->ThrowException(GetMessage('OPENID_CLIENT_ERROR_AUTH'));
     return false;
 }
示例#4
0
	function Validate()
	{
		if ($arOpenidServerTags = $this->GetOpenIDServerTags($_GET['openid_identity']))
		{
			$arParams = array(
				'openid.assoc_handle' => $_GET['openid_assoc_handle'],
				'openid.signed' => $_GET['openid_signed'],
				'openid.sig' => $_GET['openid_sig'],
			);
			$arSigned = explode(',', $_GET['openid_signed']);
			foreach ($arSigned as $s)
				$arParams['openid.' . $s] = $_GET['openid_' . str_replace('.', '_', $s)];

			$arParams['openid.mode'] = 'check_authentication';

			$str = CHTTP::sPost($arOpenidServerTags['server'], $arParams, true);

			if (preg_match('/is_valid\s*\:\s*true/' . BX_UTF_PCRE_MODIFIER, $str))
			{
				return array(
						'server' => $arOpenidServerTags['server'],
						'identity' => $_GET['openid_identity']
					);
			}
			else
			{
				$GLOBALS['APPLICATION']->ThrowException(GetMessage('OPENID_CLIENT_ERROR_AUTH'));
			}
		}
		return false;
	}
示例#5
0
	public function SendFeed($socServUserId, $message)
	{
		if(!$this->access_token || !$this->userId)
			self::SetOauthKeys($socServUserId);

		$message = CharsetConverter::ConvertCharset($message, LANG_CHARSET, "utf-8");
		$arPost = array("access_token" => $this->access_token, "message"=> $message);
		$result = CHTTP::sPost($this::GRAPH_URL."/".$this->userId."/feed", $arPost);

		if(!defined("BX_UTF"))
			$result = CharsetConverter::ConvertCharset($result, "utf-8", LANG_CHARSET);
		return CUtil::JsObjectToPhp($result);
	}
示例#6
0
	public function GetAccessToken($redirect_uri)
	{
		if($this->code === false)
			return false;

		$result = CHTTP::sPost(self::TOKEN_URL, array(
			"client_id"=>$this->appID,
			"client_secret"=>$this->appSecret,
			"code"=>$this->code,
			"redirect_uri"=>$redirect_uri,
		));

		$arResult = CUtil::JsObjectToPhp($result);

		if((isset($arResult["access_token"]) && $arResult["access_token"] <> '') && isset($arResult["user_id"]) && $arResult["user_id"] <> '')
		{
			$this->access_token = $arResult["access_token"];
			$this->userID = $arResult["user_id"];
			return true;
		}
		return false;
	}
示例#7
0
	private function RefreshToken($socServUserId)
	{
		$result = CHTTP::sPost(self::TOKEN_URL, array(
			"refresh_token"=>$this->refresh_token,
			"client_id"=>$this->appID,
			"client_secret"=>$this->appSecret,
			"grant_type"=>"refresh_token",
		));
		$arResult = CUtil::JsObjectToPhp($result);

		if(isset($arResult["access_token"]) && $arResult["access_token"] <> '')
		{
			$this->access_token = $arResult["access_token"];
			CSocServAuthDB::Update($socServUserId, array("OATOKEN" => $arResult["access_token"]));
			return true;
		}
		return false;
	}
示例#8
0
	public function GetAccessToken($redirect_uri)
	{
		if($this->code === false)
			return false;

		$result = CHTTP::sPost(self::TOKEN_URL, array(
			"code"=>$this->code,
			"client_id"=>$this->appID,
			"client_secret"=>$this->appSecret,
			"redirect_uri"=>$redirect_uri,
			"grant_type"=>"authorization_code",
		));

		$arResult = CUtil::JsObjectToPhp($result);

		if(isset($arResult["access_token"]) && $arResult["access_token"] <> '')
		{
			$this->access_token = $arResult["access_token"];
			$arguments = array();
			$arguments["application_key"] = $this->appKey;
			$arguments['method'] = 'users.getCurrentUser';
			ksort($arguments);
			$this->sign = strtolower(md5('application_key='.$arguments["application_key"].'method='.$arguments['method'].md5($this->access_token.$this->appSecret)));
			return true;
		}
		return false;
	}