当前位置: 首页>>代码示例>>PHP>>正文


PHP StdOAuth2Token::setLifetime方法代码示例

本文整理汇总了PHP中OAuth\OAuth2\Token\StdOAuth2Token::setLifetime方法的典型用法代码示例。如果您正苦于以下问题:PHP StdOAuth2Token::setLifetime方法的具体用法?PHP StdOAuth2Token::setLifetime怎么用?PHP StdOAuth2Token::setLifetime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OAuth\OAuth2\Token\StdOAuth2Token的用法示例。


在下文中一共展示了StdOAuth2Token::setLifetime方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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

示例2: parseAccessTokenResponse

 /**
  * {@inheritdoc}
  */
 protected function parseAccessTokenResponse($responseBody)
 {
     $data = json_decode($responseBody, true);
     if (is_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(0);
     if (isset($data['refresh_token'])) {
         $token->setRefreshToken($data['refresh_token']);
         unset($data['refresh_token']);
     }
     unset($data['access_token']);
     $token->setExtraParams($data);
     return $token;
 }
开发者ID:artis-mosties,项目名称:oauth-php,代码行数:22,代码来源:Pinterest.php

示例3: 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


注:本文中的OAuth\OAuth2\Token\StdOAuth2Token::setLifetime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。