【问题标题】:hybridauth : how to authenticate twitter user in yii frameworkhybridauth : 如何在 yii 框架中验证 twitter 用户
【发布时间】:2017-01-29 05:45:52
【问题描述】:

我正在学习http://www.yiiframework.com/wiki/459/integrating-hybridauth-directly-into-yii-without-an-extension/的教程

我包括了 twitter 登录,

问题是 twitter 没有返回电子邮件地址

Hybrid_User_Profile 对象([标识符] => 2378654169 [webSiteURL] => https://tisthedomainname.co/tpAnZH2BGe [profileURL] => http://twitter.com/myhjghj [photoURL] => http://pbs.twimg.com/profile_images/639065265478965088/8zty_o1K.png [displayName] => myhjghj [description] => 一些文字在这里 - https://tisthedomainname.co/0yuxRheYVD [firstName] => myhjghj [lastName] => [gender] => [语言] => [年龄] => [birthDay] => [birthMonth] => [birthYear] => [email] => [emailVerified] => [phone] => [address] => [country] => [地区] => 英国 [城市] => [zip] => )

在这个网址中https://dev.twitter.com/rest/reference/get/account/verify_credentials (并告诉我如何使用这个网址以及何时使用) 据说

“如果用户的账户中没有邮箱地址,或者邮箱地址未经验证,则返回null。”

对于 facebook 和 google,我使用电子邮件地址登录

public function login()
{
    $this->username = $this->userProfile->email;  //CUserIdentity
    Yii::app()->user->login($this, 0);
}

如果用户在 Twitter 中没有电子邮件 ID,我该如何登录?

【问题讨论】:

    标签: php twitter yii


    【解决方案1】:

    您可以查看现有身份验证机制的源代码,并从那里采取方法。

    例如:https://github.com/SleepWalker/hoauth。他是这样解释他的方法的:

    当您计划使用 Twitter 等社交网络时,返回 no 来自用户个人资料的电子邮件,您应该声明 verifyPassword($password) 或 User 模型中的 validatePassword($password) 方法,应该采用 密码(不是哈希),如果有效则返回 true。

    您还可以声明 sendActivationMail() 方法,该方法应标记 用户帐户处于非活动状态并发送邮件以进行激活。这 方法,当它存在时将用于社交网络,如 Twitter,它没有给我们关于用户电子邮件的数据(因为我们需要 证明用户输入了正确的电子邮件)。

    查看并根据需要实施。

    【讨论】:

      猜你喜欢
      • 2012-12-25
      • 1970-01-01
      • 2013-06-11
      • 1970-01-01
      • 1970-01-01
      • 2014-04-18
      • 2013-07-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多