本文整理匯總了PHP中yii\authclient\ClientInterface::getAccessToken方法的典型用法代碼示例。如果您正苦於以下問題:PHP ClientInterface::getAccessToken方法的具體用法?PHP ClientInterface::getAccessToken怎麽用?PHP ClientInterface::getAccessToken使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類yii\authclient\ClientInterface
的用法示例。
在下文中一共展示了ClientInterface::getAccessToken方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: pushSocialLink
/**
* @param \yii\authclient\ClientInterface $Client
* @return bool
* @throws \yii\web\ServerErrorHttpException
*/
public function pushSocialLink(\yii\authclient\ClientInterface $Client)
{
/** @var \cookyii\modules\Account\resources\Account\Model $self */
$self = $this;
$attributes = $Client->getUserAttributes();
/** @var $Model AccountAuthModel */
$Model = \Yii::createObject(AccountAuthModel::class);
$token = null;
if ($Client instanceof \yii\authclient\BaseOAuth) {
$Token = $Client->getAccessToken();
$token = ArrayHelper::toArray($Token);
$token['params'] = $Token->getParams();
}
return $Model::push($self->id, $Client->getId(), $attributes['id'], $token);
}
示例2: parseProvider
/**
* Parse provider
*
* @return array
*/
private function parseProvider()
{
$profile = $this->client->getUserAttributes();
$token = $this->client->getAccessToken()->getParams();
$data = [];
switch ($this->type) {
case UserProvider::TYPE_FACEBOOK:
$data = $this->parseProviderFacebook($profile, $token);
break;
case UserProvider::TYPE_VKONTAKTE:
$data = $this->parseProviderVkontakte($profile, $token);
break;
case UserProvider::TYPE_TWITTER:
$data = $this->parseProviderTwitter($profile, $token);
break;
}
$data['type'] = $this->type;
return $data;
}