如何在iphone应用程序中检索Twitter用户名?
我们如何检索iPhone用户的Twitter用户名?我可以得到Facebook的用户名。当用户登录到Facebook时,下面的代码给出了整个配置文件。我拆分此响应并获取用户名,即名字和姓氏如何在iphone应用程序中检索Twitter用户名?,iphone,twitter,Iphone,Twitter,我们如何检索iPhone用户的Twitter用户名?我可以得到Facebook的用户名。当用户登录到Facebook时,下面的代码给出了整个配置文件。我拆分此响应并获取用户名,即名字和姓氏 - (void)getFacebookProfile { NSString *urlString = [NSString stringWithFormat:@"https://graph.facebook.com/me?access_token=%@", [_accessToken stringByA
- (void)getFacebookProfile {
NSString *urlString = [NSString stringWithFormat:@"https://graph.facebook.com/me?access_token=%@", [_accessToken stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSURL *url = [NSURL URLWithString:urlString];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDidFinishSelector:@selector(getFacebookProfileFinished:)];
[request setDelegate:self];
[request startAsynchronous];
}
#pragma mark FB Responses
- (void)getFacebookProfileFinished:(ASIHTTPRequest *)request
{
// Use when fetching text data
NSString *responseString = [request responseString];
NSLog(@"Got Facebook Profile: %@", responseString);
NSMutableDictionary *responseJSON = [responseString JSONValue];
NSString *username;
NSString *firstName = [responseJSON objectForKey:@"first_name"];
NSString *lastName = [responseJSON objectForKey:@"last_name"];
if (firstName && lastName) {
username = [NSString stringWithFormat:@"%@ %@", firstName, lastName];
} else {
username = @"mysterious user";
}
//[[NSUserDefaults standardUserDefaults] setObject:@"username" forKey:@"FB_LOGIN_STATUS"];
[_loginButton setTitle:username forState:UIControlStateNormal];
[self refresh];
}
#pragma mark FBFunLoginDialogDelegate
- (void)accessTokenFound:(NSString *)accessToken {
NSLog(@"Access token found: %@", accessToken);
self.accessToken = accessToken;
_loginState = LoginStateLoggedIn;
[self dismissModalViewControllerAnimated:YES];
[self getFacebookProfile];
[self refresh];
}
我如何为Twitter实现这一点
#pragma mark SA_OAuthTwitterControllerDelegate
- (void) OAuthTwitterController: (SA_OAuthTwitterController *) controller authenticatedWithUsername: (NSString *) username {
NSLog(@"Authenicated for %@", username);
[_btnTwitter setTitle:username forState:UIControlStateNormal];
}
这是从twitter上检索用户名的代码。谢谢。但是如何在twitter上获取登录用户的其他信息,如其全名id位置等??