Iphone 使用社交框架成功登录Twitter,但无法在ios8中查看用户配置文件
以下代码是我在ios 8中使用Twitter登录时实现的。在这段代码的帮助下,我能够在设备设置的twitter应用程序中写入用户名和密码后成功登录。但我无法从Twitter获取用户的个人资料。我只能获取电子邮件地址。(twitter用户名)。下面是我的代码 在.h文件中,我导入了如下框架Iphone 使用社交框架成功登录Twitter,但无法在ios8中查看用户配置文件,iphone,ios7,twitter,Iphone,Ios7,Twitter,以下代码是我在ios 8中使用Twitter登录时实现的。在这段代码的帮助下,我能够在设备设置的twitter应用程序中写入用户名和密码后成功登录。但我无法从Twitter获取用户的个人资料。我只能获取电子邮件地址。(twitter用户名)。下面是我的代码 在.h文件中,我导入了如下框架 #import <Accounts/Accounts.h> #import <Accounts/AccountsDefines.h> #import <Social/Social.
#import <Accounts/Accounts.h>
#import <Accounts/AccountsDefines.h>
#import <Social/Social.h>
我不知道如何获取用户的其他详细信息
任何帮助都是值得的
Thanx。我使用的是相同的代码
只需尝试NSLog或Po
twitterAccount
。您将看到整个字典referee:@preetam我实现了您的代码,但出现了错误。“响应状态代码为404”。
- (IBAction)btnLoginWithTwiitterClicked:(id)sender {
//[AppCommon showProgressHUD:NSLocalizedString(@"ProgressHUD_LoadingData", @"'Loading Data','Laden van Gegevens','Daten werden geladen' -General message")];
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) // check Twitter is configured in Settings or not
{
self.accountStore = [[ACAccountStore alloc] init]; // you have to retain ACAccountStore
ACAccountType *twitterAcc = [self.accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[self.accountStore requestAccessToAccountsWithType:twitterAcc options:nil completion:^(BOOL granted, NSError *error)
{
if (granted)
{
NSArray *accountsArray = [self.accountStore accountsWithAccountType:twitterAcc];
//[AppCommon hideProgressHUD];
NSDictionary *twitterAccount = [[self.accountStore accountsWithAccountType:twitterAcc] lastObject];
NSLog(@"Twitter UserName: %@", [twitterAccount valueForKey:@"username"]);
}
else
{
if (error == nil) {
//[AppCommon hideProgressHUD];
NSLog(@"User Has disabled your app from settings...");
}
else
{
//[AppCommon hideProgressHUD];
NSLog(@"Error in Login: %@", error);
}
}
}];
}
else
{
//[AppCommon hideProgressHUD];
NSLog(@"Not Configured in Settings......"); // show user an alert view that Twitter is not configured in settings.
}
}