2016-09-21 9 views
1

私は次のコードを使ってTwitterからメールIDを取得しましたが、私はメールIDを取得できません。iOSのTwitterからメールを受け取る方法

if(session) 
{ 
    TWTRAPIClient *client = [TWTRAPIClient clientWithCurrentUser]; 
    NSURLRequest *request = [client URLRequestWithMethod:@"GET" 
                 URL:@"https://api.twitter.com/1.1/account/verify_credentials.json" 
                parameters:@{@"include_email": @"true", @"skip_status": @"true"} 
                 error:nil]; 

    [client sendTwitterRequest:request completion:^(NSURLResponse *response, NSData *data, NSError *connectionError) { 
     NSLog(@"Responce :%@",response); 

    }]; 
} 

答えて

1

解決策から少し離れています。このコードを試してください。ここ

TWTRAPIClient *client = [TWTRAPIClient clientWithCurrentUser]; 
     NSURLRequest *request = [client URLRequestWithMethod:@"GET" 
                 URL:@"https://api.twitter.com/1.1/account/verify_credentials.json" 
                parameters:@{@"include_email": @"true", @"skip_status": @"true"} 
                 error:nil]; 

     [client sendTwitterRequest:request completion:^(NSURLResponse *response, NSData *data, NSError *connectionError) { 
      NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil]; 
      NSLog(@"%@",dictionary); 
      NSURL *pictureURL = [NSURL URLWithString:dictionary[@"profile_image_url_https"]]; 
      NSData *imageData = [NSData dataWithContentsOfURL:pictureURL]; 
      NSDictionary *userDict = [NSDictionary dictionaryWithObjectsAndKeys:dictionary[@"screen_name"],@"name",dictionary[@"name"],@"email",imageData,@"image", nil]; 
     }]; 
+0

私は辞書を超える電子メールの値として名前を与えているでは、電子メールIDをretriveカント:**、 "名前" @、[ "SCREEN_NAME" @辞書]: NSDictionaryの* userDict = [NSDictionaryのをdictionaryWithObjectsAndKeys辞書[@ "name"]、@ "email" **、imageData、@ "image"、nil]; – user3908592

+1

とても仲良くしてくれてありがとう。私の仕事 –

関連する問題