Hi,
I guess I got this one from some Stackoverflow question.
Link against Social.framework and accounts.framework.
I guess I got this one from some Stackoverflow question.
Link against Social.framework and accounts.framework.
#import <Accounts/Accounts.h>
#import <Social/Social.h>
=========================================
ACAccountStore *account = [[ACAccountStore alloc] init];
ACAccountType *accountType = [account accountTypeWithAccountTypeIdentifier:
ACAccountTypeIdentifierTwitter];
[account requestAccessToAccountsWithType:accountType options:nil
completion:^(BOOL granted, NSError *error)
{
if (granted == YES)
{
NSArray *arrayOfAccounts = [account
accountsWithAccountType:accountType];
if ([arrayOfAccounts count] > 0)
{
ACAccount *twitterAccount = [arrayOfAccounts lastObject];
NSDictionary *message = @{@"status": @”My First Twitter post from iOS6”};
NSURL *requestURL = [NSURL
URLWithString:@"http://api.twitter.com/1/statuses/update.json"];
SLRequest *postRequest = [SLRequest
requestForServiceType:SLServiceTypeTwitter
requestMethod:SLRequestMethodPOST
URL:requestURL parameters:message];
postRequest.account = twitterAccount;
[postRequest performRequestWithHandler:^(NSData *responseData,
NSHTTPURLResponse *urlResponse, NSError *error)
{
NSLog(@"Twitter HTTP response: %i", [urlResponse
statusCode]);
}];
}
}
}];
That's it, don't hesitate to comment, to share your knowledge and to correct me.
Twitter for iOS6 without the modal view.