如何在 ios8 中使用 Twitter 工具包版本 1.2.0 请求检索用户电子邮件的权限?

how to request permission to retrieve user's email using twitter kit version 1.2.0 in ios8?

我已经通过关注 https://dev.twitter.com/twitter-kit/ios/configure this. I could sign-in after authentication and see my twitter name easily but now i want to retrieve my email address so i used TWTRShareEmailViewController which presents user a share email view which returns null. I went through the docs where they mentioned about my app to be whitelisted for requesting email permission and said to fill up this form https://support.twitter.com/forms/platform 在我的 ios 应用程序中集成了 Twitter 工具包 我不知道下一步该做什么?如何准确获得我的用户电子邮件权限?建议任何帮助。提前致谢。

我也没有找到要求加入白名单的具体表格。我继续他们的表格 link https://support.twitter.com/forms/platform 并检查了 "I have an API policy question not covered by these points" 选项。几天后,他们回复了我,询问了有关该应用程序及其应用程序 ID 的更多信息。我其实在等他们的回答。

编辑:

因此,在收到几封(很多)带有 support@fabric.io 的电子邮件和一些错误之后,我终于被列入了白名单。但该选项目前不适用于 Fabric,因此您必须在 apps.twitter.com 上创建一个 Twitter 应用程序。只需发送一封包含您的应用程序 ID 或您的密钥的邮件。他们可能会要求您简要说明您的应用程序,而加入白名单应该不会花那么多时间。祝你好运!

sdk-feedback@twitter.com 对话后,我将我的应用程序列入了白名单。这是故事:

  • sdk-feedback@twitter.com 发送邮件,其中包含有关您的应用程序的一些详细信息,例如消费者密钥、应用程序的应用程序商店 link、Link 隐私政策、元数据、有关如何登录我们的应用程序的说明。在邮件中提及您想要在您的应用程序中访问用户电子邮件地址。

  • 他们会审核您的应用并在 2-3 个工作日内回复您。

  • 一旦他们说您的应用已列入白名单,请在 Twitter 开发者门户中更新您的应用设置。登录 apps.twitter.com 和:

    1. 在 'Settings' 选项卡上,添加服务条款和隐私政策 URL
    2. 在 'Permissions' 选项卡上,将令牌的范围更改为请求电子邮件。只有在您的应用程序被列入白名单后,才会看到此选项。

该打码了:

-(void)requestUserEmail
{
    if ([[Twitter sharedInstance] session]) {

        TWTRShareEmailViewController *shareEmailViewController =
        [[TWTRShareEmailViewController alloc]
         initWithCompletion:^(NSString *email, NSError *error) {
             NSLog(@"Email %@ | Error: %@", email, error);
         }];

        [self presentViewController:shareEmailViewController
                           animated:YES
                         completion:nil];
    } else {
        // Handle user not signed in (e.g. attempt to log in or show an alert)
    }
}

希望对您有所帮助!!!

发送电子邮件至 sdk-feedback@twitter.com 以首先将您的 Twitter 登录应用列入白名单。

Swift 3.0 代码与 fabric

@IBAction func btnTwitterAction(_ sender: AnyObject) {
        Twitter.sharedInstance().logIn { (session, error) in
            if session != nil {
                print("signed in as \(session!.userName)");
                let client = TWTRAPIClient.withCurrentUser()
                let request = client.urlRequest(withMethod: "GET",
                                                url: "https://api.twitter.com/1.1/account/verify_credentials.json?include_email=true",
                                                          parameters: ["include_email": "true", "skip_status": "true"],
                                                          error: nil)
                client.sendTwitterRequest(request) { response, data, connectionError in
                    if (connectionError == nil) {

                        do{
                            let json = try JSONSerialization.jsonObject(with: data!, options: .allowFragments) as! [String:Any]
                            print("Json response: ", json)
                            let firstName = json["name"]
                            let lastName = json["screen_name"]
                            let email = json["email"]
                            print("First name: ",firstName)
                            print("Last name: ",lastName)
                            print("Email: ",email)
                        } catch {

                        }

                    }
                    else {
                        print("Error: \(connectionError)")
                    }
                }


            } else {
                NSLog("Login error: %@", error!.localizedDescription);
            }
        }
    }

我最近遇到了同样的问题

如果您正在使用新的 Twitter 工具包,您应该尝试以下方法

转到

代码:

Twitter.sharedInstance().logIn(withMethods: [.webBased,.systemAccounts,.all]) {(session, error) -> Void in

        if (session != nil) {
            print("signed in as \(session?.userName)");

            let client = TWTRAPIClient(userID: session?.userName)
            client.loadUser(withID: (session?.userID)!, completion: { (user, error) in

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


                twitterClient.sendTwitterRequest(request) { response, data, connectionError in

                    print(data!)

                    let s :String = String(data: data! as Data, encoding: String.Encoding.utf8)!
                    //
                    //            let json = try JSONSerialization.jsonObject(with: responseData as Data, options: JSONSerialization.ReadingOptions.mutableLeaves) as? [String:AnyObject]
                    //

                    Twitter.sharedInstance().sessionStore.logOutUserID((session?.userID)!)

                    if let data = s.data(using: String.Encoding.utf8) {
                        do {
                            let json = try JSONSerialization.jsonObject(with: data, options: .mutableContainers) as? [String:Any]
                            print(json!)

                        } catch {
                            print("Something went wrong")
                        }
                    }
                }
            })

        } else {
   }

如何在 Twitter 中获取电子邮件 ID?

第 1 步:到达 https://apps.twitter.com/app/

第 2 步:点击您的应用 > 点击权限选项卡。

第 3 步:在这里检查邮箱