Skip to content

Instantly share code, notes, and snippets.

@kenshin03
Created April 30, 2013 08:55
Show Gist options
  • Save kenshin03/5487495 to your computer and use it in GitHub Desktop.
Save kenshin03/5487495 to your computer and use it in GitHub Desktop.
Facebook Graph API request with ACAccountStore refer to https://gist.github.com/kenshin03/5487487 for the initAccount part
- (void) likeFeed:(NSString*)graphID {
InitAccountSuccessBlock successBlock = ^{
NSString * likeURLString = [NSString stringWithFormat:@"https://graph.facebook.com/%@/likes", graphID];
NSURL * feedURL = [NSURL URLWithString:likeURLString];
SLRequest * request = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodPOST URL:feedURL parameters:nil];
NSLog(@"request.URL: %@", request.URL);
request.account = self.facebookAccount;
[request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
NSString * responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
NSLog(@"responseString: %@", responseString);
}];
};
if (self.facebookAccount == nil){
[self initAccount:successBlock];
}else{
successBlock();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment