首先,您無法使用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