ios - 无法从 Twitter 登录获取电子邮件

标签 ios swift twitter firebase-authentication twitter-oauth

几天来我一直在尝试从 Twitter 登录中获取电子邮件。根据文档和堆栈溢出做了一切。仍然得到相同的响应,此用户没有电子邮件地址。。尝试使用 2 种方法获取电子邮件。

方法一:(这里的json不包含email)

let request = TWTRAPIClient.withCurrentUser().urlRequest(withMethod: "GET", url: "https://api.twitter.com/1.1/account/verify_credentials.json", parameters: ["include_email": "true", "skip_status": "true"], error: nil)

    TWTRAPIClient.withCurrentUser().sendTwitterRequest(request, completion: { (response, data, error) in

        if let error = error {
            print(error.localizedDescription)
            return
        }
        guard let data = data else { return }
        do {
            if let json = try JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? [String: AnyObject] {
                print(json) // this json did not contain email
            }
        } catch let jsonError {
            print(jsonError)
        }
    })

方法 2:(总是报错说 此用户没有电子邮件地址。)

TWTRAPIClient.withCurrentUser().requestEmail(forCurrentUser: { (email, error) in
    if let error = error {
        print(error.localizedDescription) // gave output "This user does not have an email address."
        return
    }
    if let email = email {
        print(email)
    }
})

多次生成新 key 并在 App 内更新它们。仍然出现相同的错误。 Android 应用程序使用与 iOS 中使用的 key 相同的 key 来成功获取电子邮件。提前致谢。

最佳答案

要获取用户电子邮件地址,您的应用程序应该被列入白名单。 Use this form .您可以将邮件发送至 sdk-feedback@twitter.com,其中包含有关您的应用程序的一些详细信息,例如消费者 key 、应用程序的应用程序商店链接、隐私政策链接、元数据、有关如何登录我们应用程序的说明等。他们将在 2-3 个工作日内回复。

在您的应用被列入白名单后,您可以使用 Twitter Framework 或 API 来接收电子邮件。

关于ios - 无法从 Twitter 登录获取电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48781779/

相关文章:

ios - 如何在应用加载时选择文本?

ios - 将 UITextField 添加到 ScrollView

ios - AVCaptureSession - 在帧的特定部分内进行捕获

ios - 如何更改Apple Research Kit中预定义按钮的颜色

ios - 如何为iOS应用程序React-Native配置最低应用程序版本

android - 使用 Kotlin 登录 Twitter

python - Tweepy 跟踪条款和关注用户

python - word2vec:具有预训练模型的用户级、文档级嵌入

iphone - IOS 开发,使用 UIImagePickerController 并按下使用会使应用卡住(不崩溃)

ios - Swift 2 的 Xcode 7.0 更新问题