Skip to content

Instantly share code, notes, and snippets.

@balazsnemeth
Created March 30, 2015 22:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save balazsnemeth/cbe7f4ea38abe3df19fb to your computer and use it in GitHub Desktop.
Save balazsnemeth/cbe7f4ea38abe3df19fb to your computer and use it in GitHub Desktop.
Post Twitter status dictionary
- (void) postTwitterStatus:(NSDictionary *)statusParameters withCompletion:(void(^)(NSError *error))completion {
NSAssert(twitterIsSetUp && self.accounts.count > 0, @"To post something to twitter, the twitter API should be set up already");
ACAccount *twitterAccount = [self.accounts objectAtIndex:0];
NSURL * requestURL = [NSURL URLWithString:@"https://api.twitter.com/1.1/statuses/update.json"];
SLRequest *postRequest = [SLRequest
requestForServiceType:SLServiceTypeTwitter
requestMethod:SLRequestMethodPOST
URL:requestURL parameters:statusParameters];
postRequest.account = twitterAccount;
[postRequest performRequestWithHandler:
^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error)
{
NSString *resp = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
DLog(@"restp with media: %@",resp);
if (error) {
NSLog(@"%@",error.description);
}
else {
DLog(@"Tweet Success");
}
if (completion) {
completion(error);
}
}];
self.slReq = postRequest;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment