Skip to content

Instantly share code, notes, and snippets.

View melsam's full-sized avatar

Mel Sampat melsam

View GitHub Profile
@melsam
melsam / TwitterStatusUpdateWithoutUI.m
Last active October 24, 2016 12:05
Post a Twitter status update without using any of the built-in UI on iOS. This uses the Twitter 1.1 API (not the deprecated REST APIs).
@import Accounts;
#import <Twitter/Twitter.h>
- (void)postTwitterStatusUpdate:(NSString *)statusMessage
{
ACAccountStore *account = [ACAccountStore new];
ACAccountType *accountType = [account accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[account requestAccessToAccountsWithType:accountType options:nil completion:^(BOOL granted, NSError *error) {
if (granted) {