I’m using the following code to get the user details from Twitter in iOS 5.
if ([TWTweetComposeViewController canSendTweet])
{
// Create account store, followed by a Twitter account identifer
account = [[ACAccountStore alloc] init];
ACAccountType *accountType = [account accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
// Request access from the user to use their Twitter accounts.
[account requestAccessToAccountsWithType:accountType withCompletionHandler:^(BOOL granted, NSError *error)
{
// Did user allow us access?
if (granted == YES)
{
// Populate array with all available Twitter accounts
arrayOfAccounts = [account accountsWithAccountType:accountType];
[arrayOfAccounts retain];
// Populate the tableview
if ([arrayOfAccounts count] > 0)
[self performSelectorOnMainThread:@selector(updateTableview) withObject:NULL waitUntilDone:NO];
}
}];
}
//
-(void)updateTableview
{
numberOfTwitterAccounts = [arrayOfAccounts count];
NSLog(@"Twiter details-- %@",[arrayOfAccounts objectAtIndex:0]);
}
In my NSLog console, I am getting the output as follows:
Twiter details-- type:com.apple.twitter
identifier: E8591841-2AE0-4FC3-8ED8-F286BE7A36B0
accountDescription: @Sadoo55
username: sadukoyghdkwed@gmail.com
objectID: x-coredata://F8059811-CFB2-4E20-BD88-F4D06A43EF11/Account/p8
enabledDataclasses: {(
)}
properties: {
"user_id" = 308905856;
}
parentAccount: (null)
owningBundleID:com.apple.Preferences
I want to get the “user_id” from this. How can I fetch “user_id” (ie. 308905856)?
Getting the user ID &/or username is much easier than that.
iOS 7 version
or
iOS 5 version
There was an undocumented method of ACAccount called accountProperties of type NSDictionary with a user_id key.
**Does not work under iOS6 because the method is no longer defined.