首先,您无法使用iOS7框架或Twitter的Native API从Twitter的API获取用户电子邮件地址。
如果你想获得用户的电子邮件地址,你可以要求用户手动输入。这就是Twitter人在他们的API文档中所说的。对于你的第2点和第3点,这里是使用iOS7的示例代码
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)
{
self.twitterAccount = [[self.accountStore accountsWithAccountType:twitterAcc] lastObject];
NSLog(@"Twitter UserName: %@, FullName: %@", self.twitterAccount.username, self.twitterAccount.userFullName);
[self getTwitterEmail]; // here you can ask user to enter email address. Its up to you how you ask user about it. Either in alert View or in Text Field.
}
else
{
if (error == nil) {
NSLog(@"User Has disabled your app from settings...");
}
else
{
NSLog(@"Error in Login: %@", error);
}
}
}];
}
else
{
NSLog(@"Not Configured in Settings......"); // show user an alert view that Twitter is not configured in settings.
}
你有没有做过这方面的事情? – DAMM108
@ DAMMM108:谢谢你的回复我已经通过使用旧的Twitter的API,但我想从iOS标准库做到这一点。可能吗?谢谢 –
没有这不可能从ios标准框架,而是使用https://github.com/nst/STTwitter,它是一个好的 – DAMM108