Created
March 30, 2015 22:01
-
-
Save balazsnemeth/cbe7f4ea38abe3df19fb to your computer and use it in GitHub Desktop.
Post Twitter status dictionary
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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