Reputation: 3081
I was able to post a status update to Facebook user wall through the iOS app I'm developing a few days ago. Then I probably accidentally removed something, I now cannot post and get error message. The relevant code is A:
message = @"test";
[FBRequestConnection startForPostStatusUpdate:message
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
}
I also tried following method B:
[FBRequestConnection startWithGraphPath:@"me/feed" parameters:postParams HTTPMethod:@"POST" completionHandler:^(FBRequestConnection *connection,id result,NSError *error)
and I got same error message: The operation couldn’t be completed. (com.facebook.sdk error 5.)"
I also noticed doesn't matter if I use FacebookSDK.h or Facebook.h for either method, both (four ways) would all get the same error message above. I also wonder why FacebookSDK.h is enough to support two methods above, why the tutorial suggests deprecated Facebook.h.
Interesting, I went to check another testing iOS app that I remember could post Facebook status update, and found it could not post either. Any idea?
Upvotes: 2
Views: 952
Reputation: 3081
I decided to use iOS6 feature SLComposeViewController, which makes posting Facebook status update a piece of cake.
After add Social framework in your .m file, you can do sth like this:
- (IBAction)clickMe:(UIButton *)sender {
NSLog(@"you clicked me");
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
SLComposeViewController* myFB = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result) {
if (result == SLComposeViewControllerResultCancelled) {
NSLog(@"cancelled");
} else {
NSLog(@"oh yeah");
}
[myFB dismissViewControllerAnimated:YES completion:nil];
};
myFB.completionHandler = myBlock;
[myFB setInitialText:@"Posting from my app."];
[self presentViewController:myFB animated:YES completion:nil];
}
}
Upvotes: 1