2017-02-21 64 views
1

如何獲取詳細信息,如個人資料圖片和更多的信息,而Twitter登錄IOS使用Fabric。 我寫這篇文章的代碼 -獲取詳細信息像個人資料圖片和更多信息,而IOS登錄IOS 10.2使用結構

[[Twitter sharedInstance] logInWithCompletion:^ 
    (TWTRSession *session, NSError *error) { 
     if (session) { 
      /* Get user info */ 

      [[[Twitter sharedInstance] APIClient] loadUserWithID:[session userID] 
                 completion:^(TWTRUser *user, 
                    NSError *error) 
       { 
        // handle the response or error 
        if (![error isEqual:nil]) { 
         NSLog(@"Twitter info -> user = %@ ",user); 
         NSString *urlString = [[NSString alloc]initWithString:user.profileImageLargeURL]; 
         NSURL *url = [[NSURL alloc]initWithString:urlString]; 
         NSData *pullTwitterPP = [[NSData alloc]initWithContentsOfURL:url]; 

         UIImage *profImage = [UIImage imageWithData:pullTwitterPP]; 


        } else { 
         NSLog(@"Twitter error getting profile : %@", [error localizedDescription]); 
        } 
       }]; 


     } else { 
      NSLog(@"error: %@", [error localizedDescription]); 
     } 
    }]; 

但它表明這種類型的錯誤: enter image description here

回答

1

我終於找到了答案我自己:

[[Twitter sharedInstance] logInWithCompletion:^ 
(TWTRSession *session, NSError *error) { 
    if (session) { 

     NSLog(@"signed in as %@", [session userName]); 
     /* Get user info */ 

     NSString *userID = [Twitter sharedInstance].sessionStore.session.userID; 
     TWTRAPIClient *client = [[TWTRAPIClient alloc] initWithUserID:userID]; 
     [client loadUserWithID:userID completion:^(TWTRUser *user, NSError *error) { 
      NSLog(@"Profile image url = %@", user.profileImageLargeURL); 
     }]; 


    } else { 
     NSLog(@"error: %@", [error localizedDescription]); 
    } 
}]; 

它給你的個人資料圖片的網址。

+0

完美的作品,謝謝! – Tim

+0

蒂姆你最歡迎! –

相關問題