I am getting the following error when trying to post to the user's Facebook wall and I can't seem to find the source. Anyone have some insight on this issue?
2012-08-29 22:14:38.490 CanP[405:707] Error: HTTP status code: 400
2012-08-29 22:14:38.494 CanP[405:707] FBSDKLog: Response <#1111> <Error>:
The operation couldn’t be completed. (com.facebook.sdk error 5.)
The method that is run that should post the message to the facebook wall is as follows:
[FBSettings setLoggingBehavior:[NSSet setWithObjects:
FBLoggingBehaviorFBRequests,
nil]];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[facebook accessToken] forKey:@"FBAccessTokenKey"];
[defaults setObject:[facebook expirationDate] forKey:@"FBExpirationDateKey"];
[defaults synchronize];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"My test app", @"name",
@"http://www.google.com", @"link",
@"FBTestApp app for iPhone!", @"caption",
@"This is a description of my app", @"description",
@"Hello!\n\nThis is a test message\nfrom my test iPhone app!", @"message",
nil];
// Publish.
// This is the most important method that you call. It does the actual job, the message posting.
[facebook requestWithGraphPath:@"me/feed" andParams:params andHttpMethod:@"POST" andDelegate:self];
I would suggest that you use the new SDK 3.1 methods for posting.
[FBRequestConnection
startWithGraphPath:@"me/feed"
parameters:params
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error) {
if (error) {
/* Handle error */
} else {
/* Handle success */
}
}];
For a step by step tutorial, see: https://developers.facebook.com/docs/howtos/publish-to-feed-ios-sdk/
Also make sure you ask for publish_action permissions first to make sure you can post to the wall.
If you still run into issues, place a breakpoint at the error line and take a look at the error variable then drill down to a dictionary named userInfo that should contain a much more readable error message.