-
StackOverflow 文件
-
yii2 教程
-
Yii2 OAuth2 - 前消費者臉書 OAuth2
-
onAuthSuccess 函式的示例
/**
* @param $client ClientInterface
*/
public function onAuthSuccess($client)
{
//Get user info
/** @var array $attributes */
$attributes = $client->getUserAttributes();
$email = ArrayHelper::getValue($attributes, 'email'); //email info
$id = ArrayHelper::getValue($attributes, 'id'); // id facebook user
$name = ArrayHelper::getValue($attributes, 'name'); // name facebook account
//Login user
//For demo, I will login with admin/admin default account
$admin = User::findByUsername('admin');
Yii::$app->user->login($admin);
}