我一直在尝试从Twitter登录中获取电子邮件几天。根据文档和堆栈溢出所做的一切。仍然得到相同的响应,This user does not have an email address.
。试图用2种方法获取电子邮件。
方法1 :(这里的JSON不包含电子邮件(
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 :(始终给出错误说This user does not have an email address.
(
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)
}
})
多次生成了新键,并在应用程序中更新了它们。仍然遇到相同的错误。使用iOS中使用的相同密钥,Android应用程序获取电子邮件。预先感谢。
要获取用户电子邮件地址,应将您的应用程序列入白色。使用此表格。您可以将邮件发送到sdk-feedback@twitter.com,并提供有关您的应用程序的一些详细信息,例如消费者密钥,应用程序的应用商店链接,链接到隐私策略,元数据,有关如何登录我们的应用程序等的说明。在2-3个工作日内做出回应。
将应用程序列入白色,您可以使用Twitter框架或API获取电子邮件。