Unable to fetch user's email from twitter using twitter fabric iOS framework -


i trying hands on new fabric twitter kit ios. after signing in can ask user allow access email id , if allows returns email of logged in user giving me error.

email (null), error: error domain=nsurlerrordomain code=-1001  "the request timed out." userinfo=0x7fdd314f1c30  {nsunderlyingerror=0x7fdd314d9aa0 "the request timed out.",  nserrorfailingurlstringkey=https://api.twitter.com/1.1/account/verify_cre dentials.json?skip_status=true&include_email=true,  nserrorfailingurlkey=https://api.twitter.com/1.1/account/verify_credentia ls.json?skip_status=true&include_email=true,  nslocalizeddescription=the request timed out.} 

and here code i've tried doc.

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 {     // todo: handle user not signed in (e.g.     // attempt log in or show alert) } 

is wrong in code? please me. can post status , media twitter can't email id.

can please me in problem? i'm new development.

to user email address, application should whitelisted. here link. go use form. can either send mail sdk-feedback@twitter.com details app consumer key, app store link of app, link privacy policy, metadata, instructions on how log our app etc..they respond within 2-3 working days.

here story how got whitelisted conversation twitter support team:

  • send mail sdk-feedback@twitter.com details app consumer key, app store link of app, link privacy policy, metadata, instructions on how log our app. mention in mail want access user email adress inside app.

  • they review app , reply withing 2-3 business days.

  • once app whitelisted, update app's settings in twitter developer portal. sign in apps.twitter.com and:

    1. on 'settings' tab, add terms of service , privacy policy url
    2. on 'permissions' tab, change token's scope request email. option been seen, once app gets whitelisted.

put hands on code

use of twitter framework:

get user email address

-(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 log in or show alert)         }     } 

get user profile

-(void)usersshow:(nsstring *)userid {     nsstring *statusesshowendpoint = @"https://api.twitter.com/1.1/users/show.json";     nsdictionary *params = @{@"user_id": userid};      nserror *clienterror;     nsurlrequest *request = [[[twitter sharedinstance] apiclient]                              urlrequestwithmethod:@"get"                              url:statusesshowendpoint                              parameters:params                              error:&clienterror];      if (request) {         [[[twitter sharedinstance] apiclient]          sendtwitterrequest:request          completion:^(nsurlresponse *response,                       nsdata *data,                       nserror *connectionerror) {              if (data) {                  // handle response data e.g.                  nserror *jsonerror;                  nsdictionary *json = [nsjsonserialization                                        jsonobjectwithdata:data                                        options:0                                        error:&jsonerror];                  nslog(@"%@",[json description]);              }              else {                  nslog(@"error code: %ld | error description: %@", (long)[connectionerror code], [connectionerror localizeddescription]);              }          }];     }     else {         nslog(@"error: %@", clienterror);     } } 

hope helps !!!


Comments