當前位置: 首頁>>代碼示例>>PHP>>正文


PHP StdOAuth2Token::setExtraParams方法代碼示例

本文整理匯總了PHP中OAuth\OAuth2\Token\StdOAuth2Token::setExtraParams方法的典型用法代碼示例。如果您正苦於以下問題:PHP StdOAuth2Token::setExtraParams方法的具體用法?PHP StdOAuth2Token::setExtraParams怎麽用?PHP StdOAuth2Token::setExtraParams使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OAuth\OAuth2\Token\StdOAuth2Token的用法示例。


在下文中一共展示了StdOAuth2Token::setExtraParams方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: parseAccessTokenResponse

 protected function parseAccessTokenResponse($responseBody)
 {
     if (version_compare($this->apiVersion, 'v2.2', '>') === true) {
         $data = json_decode($responseBody, true);
     } else {
         parse_str($responseBody, $data);
     }
     if (null === $data || !is_array($data)) {
         throw new TokenResponseException('Unable to parse response.');
     } elseif (isset($data['error'])) {
         if (is_array($data['error']) === true) {
             $errorMessage = $data['error']['message'];
         } else {
             $errorMessage = $data['error'];
         }
         throw new TokenResponseException('Error in retrieving token: "' . $errorMessage . '"');
     }
     $token = new StdOAuth2Token();
     $token->setAccessToken($data['access_token']);
     if (isset($data['expires'])) {
         $token->setLifeTime($data['expires']);
     }
     if (isset($data['refresh_token'])) {
         $token->setRefreshToken($data['refresh_token']);
         unset($data['refresh_token']);
     }
     unset($data['access_token']);
     unset($data['expires']);
     $token->setExtraParams($data);
     return $token;
 }
開發者ID:recca0120,項目名稱:socialite,代碼行數:31,代碼來源:Facebook.php

示例2: parseAccessTokenResponse

 /**
  * Parses the access token response and returns a TokenInterface.
  *
  *
  * @param string $responseBody
  *
  * @return TokenInterface
  *
  * @throws TokenResponseException
  */
 protected function parseAccessTokenResponse($responseBody)
 {
     $request = \Request::getInstance();
     if ($request->get('error')) {
         $reason = $request->get('error_description');
         throw new TokenResponseException($reason);
     }
     $data = json_decode($responseBody, true);
     if (null === $data || !is_array($data)) {
         throw new TokenResponseException('Unable to parse response.');
     } elseif (isset($data['error'])) {
         throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
     }
     $token = new StdOAuth2Token();
     $token->setAccessToken($data['access_token']);
     $token->setLifetime($data['expires_in']);
     if (isset($data['refresh_token'])) {
         $token->setRefreshToken($data['refresh_token']);
         unset($data['refresh_token']);
     }
     unset($data['access_token']);
     unset($data['expires_in']);
     $data['state'] = $request->get('state');
     $token->setExtraParams($data);
     return $token;
 }
開發者ID:ppiedaderawnet,項目名稱:concrete5,代碼行數:36,代碼來源:Community.php

示例3: parseAccessTokenResponse

 /**
  * {@inheritdoc}
  */
 protected function parseAccessTokenResponse($responseBody)
 {
     $data = json_decode($responseBody, true);
     if (null === $data || !is_array($data)) {
         throw new TokenResponseException('Unable to parse response.');
     } elseif (isset($data['error'])) {
         throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
     }
     $token = new StdOAuth2Token();
     $token->setAccessToken($data['access_token']);
     unset($data['access_token']);
     $token->setExtraParams($data);
     return $token;
 }
開發者ID:orottier,項目名稱:PHPoAuthLib,代碼行數:17,代碼來源:Slack.php

示例4: parseAccessTokenResponse

 /**
  * {@inheritdoc}
  */
 protected function parseAccessTokenResponse($responseBody)
 {
     $data = json_decode($responseBody, true);
     if (null === $data || !is_array($data)) {
         throw new TokenResponseException('Unable to parse response.');
     } elseif (isset($data['error'])) {
         throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
     }
     $token = new StdOAuth2Token();
     $token->setAccessToken($data['access_token']);
     // Foursquare tokens evidently never expire...
     $token->setEndOfLife(StdOAuth2Token::EOL_NEVER_EXPIRES);
     unset($data['access_token']);
     $token->setExtraParams($data);
     return $token;
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:19,代碼來源:Foursquare.php

示例5: parseAccessTokenResponse

 protected function parseAccessTokenResponse($responseBody)
 {
     parse_str($responseBody, $data);
     if ($data === null || !is_array($data)) {
         throw new TokenResponseException('Unable to parse response.');
     } elseif (isset($data['error'])) {
         throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
     }
     $token = new StdOAuth2Token();
     #$token->setRequestToken($data['access_token']);
     $token->setAccessToken($data['access_token']);
     $token->setEndOfLife(StdOAuth2Token::EOL_NEVER_EXPIRES);
     unset($data['access_token']);
     $token->setExtraParams($data);
     return $token;
 }
開發者ID:DevSlashNull,項目名稱:PHPoAuthLib,代碼行數:16,代碼來源:Pocket.php

示例6: parseAccessTokenResponse

 /**
  * {@inheritdoc}
  */
 protected function parseAccessTokenResponse($responseBody)
 {
     $data = json_decode($responseBody, true);
     if (null === $data || !is_array($data)) {
         throw new TokenResponseException('Unable to parse response.');
     } elseif (isset($data['error_description']) || isset($data['error'])) {
         throw new TokenResponseException(sprintf('Error in retrieving token: "%s"', isset($data['error_description']) ? $data['error_description'] : $data['error']));
     }
     $token = new StdOAuth2Token();
     $token->setAccessToken($data['access_token']);
     $token->setLifeTime($data['expires_in']);
     if (isset($data['refresh_token'])) {
         $token->setRefreshToken($data['refresh_token']);
         unset($data['refresh_token']);
     }
     unset($data['access_token']);
     unset($data['expires_in']);
     $token->setExtraParams($data);
     return $token;
 }
開發者ID:vladvoth,項目名稱:productclash,代碼行數:23,代碼來源:Dailymotion.php

示例7: parseAccessTokenResponse

 /**
  * {@inheritdoc}
  */
 protected function parseAccessTokenResponse($responseBody)
 {
     // Facebook gives us a query string ... Oh wait. JSON is too simple, understand ?
     parse_str($responseBody, $data);
     if (null === $data || !is_array($data)) {
         throw new TokenResponseException('Unable to parse response.');
     } elseif (isset($data['error'])) {
         throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
     }
     $token = new StdOAuth2Token();
     $token->setAccessToken($data['access_token']);
     $token->setLifeTime($data['expires']);
     if (isset($data['refresh_token'])) {
         $token->setRefreshToken($data['refresh_token']);
         unset($data['refresh_token']);
     }
     unset($data['access_token']);
     unset($data['expires']);
     $token->setExtraParams($data);
     return $token;
 }
開發者ID:carriercomm,項目名稱:sticky-notes,代碼行數:24,代碼來源:Facebook.php

示例8: parseAccessTokenResponse

 /**
  * {@inheritdoc}
  */
 protected function parseAccessTokenResponse($responseBody)
 {
     $JSON = new \JSON(JSON_LOOSE_TYPE);
     $data = $JSON->decode($responseBody);
     if (null === $data || !is_array($data)) {
         throw new TokenResponseException('Unable to parse response.');
     } elseif (isset($data['error'])) {
         throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
     }
     $token = new StdOAuth2Token();
     $token->setAccessToken($data['access_token']);
     if (isset($data['expires'])) {
         $token->setLifeTime($data['expires']);
     }
     if (isset($data['refresh_token'])) {
         $token->setRefreshToken($data['refresh_token']);
         unset($data['refresh_token']);
     }
     unset($data['access_token']);
     unset($data['expires']);
     $token->setExtraParams($data);
     return $token;
 }
開發者ID:araname,項目名稱:dokuwiki-plugin-oauth,代碼行數:26,代碼來源:Auth0.php

示例9: parseAccessTokenResponse

 /**
  * @param string $responseBody
  * @return StdOAuth2Token
  * @throws TokenResponseException
  */
 protected function parseAccessTokenResponse($responseBody)
 {
     $data = $this->service->parseAccessTokenResponse($responseBody);
     if (!isset($data) || !is_array($data)) {
         throw new TokenResponseException('Unable to parse response.');
     }
     $error = $this->service->getAccessTokenResponseError($data);
     if (isset($error)) {
         throw new TokenResponseException('Error in retrieving token: "' . $error . '"');
     }
     $token = new StdOAuth2Token();
     $names = $this->service->getAccessTokenArgumentNames();
     $token->setAccessToken($data[$names['access_token']]);
     unset($data[$names['access_token']]);
     if (isset($data[$names['expires_in']])) {
         $token->setLifeTime($data[$names['expires_in']]);
         unset($data[$names['expires_in']]);
     } else {
         $token->setLifetime($this->service->getTokenDefaultLifetime());
     }
     if (isset($data[$names['refresh_token']])) {
         $token->setRefreshToken($data[$names['refresh_token']]);
         unset($data[$names['refresh_token']]);
     }
     $token->setExtraParams($data);
     return $token;
 }
開發者ID:barbq,項目名稱:yii2eauth,代碼行數:32,代碼來源:ServiceProxy.php

示例10: parseAccessTokenResponse

 /** -----------------------------------------------------------------------
  * {@inheritdoc}
  */
 protected function parseAccessTokenResponse($responseBody)
 {
     $data = json_decode($responseBody, true);
     if ($data === null || !is_array($data)) {
         throw new TokenResponseException('Unable to parse response.');
     } elseif (isset($data['error'])) {
         $err = $data['error'];
         throw new TokenResponseException("Error in retrieving token: \"{$err}\"");
     }
     $token = new StdOAuth2Token($data['access_token'], null, $data['expires_in']);
     unset($data['access_token']);
     unset($data['expires_in']);
     $token->setExtraParams($data);
     return $token;
 }
開發者ID:RewardGateway,項目名稱:PHPoAuthLib,代碼行數:18,代碼來源:BattleNet.php

示例11: parseAccessTokenResponse

 /**
  * {@inheritdoc}
  */
 protected function parseAccessTokenResponse($responseBody)
 {
     $data = json_decode($responseBody, true);
     if (null === $data || !is_array($data)) {
         throw new TokenResponseException('Unable to parse response.');
     } elseif (isset($data['error'])) {
         throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
     }
     $token = new StdOAuth2Token();
     $token->setAccessToken($data['access_token']);
     // Salesforce access tokens depend on the session timeout settings.
     // The session timeout for an access token can be configured in Salesforce from Setup by clicking Security Controls | Session Settings.
     $token->setEndOfLife(StdOAuth2Token::EOL_UNKNOWN);
     unset($data['access_token']);
     if (isset($data['refresh_token'])) {
         $token->setRefreshToken($data['refresh_token']);
         // Save Refresh Token persistently until it is cleared manually
         update_option('gf_salesforce_refreshtoken', $data['refresh_token']);
         unset($data['refresh_token']);
     } else {
         $refresh_token = get_option('gf_salesforce_refreshtoken');
         if (!empty($refresh_token)) {
             $token->setRefreshToken($refresh_token);
         }
     }
     $token->setExtraParams($data);
     return $token;
 }
開發者ID:AgilData,項目名稱:WordPress-Skeleton,代碼行數:31,代碼來源:Salesforce.php

示例12: parseAccessTokenResponse

 /**
  * {@inheritdoc}
  */
 protected function parseAccessTokenResponse($responseBody)
 {
     $data = @json_decode($responseBody, true);
     // Facebook gives us a query string on old api (v2.0)
     if (!$data) {
         parse_str($responseBody, $data);
     }
     if (null === $data || !is_array($data)) {
         throw new TokenResponseException('Unable to parse response.');
     } elseif (isset($data['error'])) {
         throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
     }
     $token = new StdOAuth2Token();
     $token->setAccessToken($data['access_token']);
     if (isset($data['expires'])) {
         $token->setLifeTime($data['expires']);
     }
     if (isset($data['refresh_token'])) {
         $token->setRefreshToken($data['refresh_token']);
         unset($data['refresh_token']);
     }
     unset($data['access_token']);
     unset($data['expires']);
     $token->setExtraParams($data);
     return $token;
 }
開發者ID:RewardGateway,項目名稱:PHPoAuthLib,代碼行數:29,代碼來源:Facebook.php

示例13: parseAccessTokenResponse

 /**
  * {@inheritdoc}
  */
 protected function parseAccessTokenResponse($responseBody)
 {
     parse_str($responseBody, $data);
     if (null === $data || !is_array($data) || empty($data)) {
         throw new TokenResponseException('Unable to parse response.');
     } elseif (isset($data['error'])) {
         throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
     } elseif (isset($data['error_reason'])) {
         throw new TokenResponseException('Error in retrieving token: "' . $data['error_reason'] . '"');
     }
     $token = new StdOAuth2Token();
     $token->setAccessToken($data['access_token']);
     $token->setLifeTime($data['expires']);
     // I hope one day Deezer add a refresh token :)
     if (isset($data['refresh_token'])) {
         $token->setRefreshToken($data['refresh_token']);
         unset($data['refresh_token']);
     }
     unset($data['access_token']);
     unset($data['expires']);
     $token->setExtraParams($data);
     return $token;
 }
開發者ID:DevSlashNull,項目名稱:PHPoAuthLib,代碼行數:26,代碼來源:Deezer.php


注:本文中的OAuth\OAuth2\Token\StdOAuth2Token::setExtraParams方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。