Organizational Research By

Surprising Reserch Topic

ios facebook sdk 3 0 error 5 when posting status update using -'ios,facebook,facebook-ios-sdk'

ios facebook sdk 3 0 error 5 when posting status update  using -'ios,facebook,facebook-ios-sdk'

I am trying out adding facebook integration in an app using the new (beta) facebook ios sdk 3.0. All I would like to is post a status update to facebook. I used a FBLoginView to login to facebook. I put my app id in the plist as instructed on facebook. I put in some code to post to facebook.

[super viewDidLoad];
NSArray *perms;
perms = [NSArray arrayWithObjects:@"status_update", nil];
FBLoginView *loginview =
[[FBLoginView alloc] initWithPermissions:perms];

loginview.frame = CGRectOffset(loginview.frame, 5, 5);
loginview.delegate = self;

[self.view addSubview:loginview];
// Do any additional setup after loading the view, typically from a nib.


- (IBAction)poststatus:(UIButton *)sender {
NSString *message = [NSString stringWithFormat:@"Test staus update"];

[FBRequestConnection startForPostStatusUpdate:message
                            completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {

                                [self showAlert:message result:result error:error];

- (void)showAlert:(NSString *)message
        error:(NSError *)error {

NSString *alertMsg;
NSString *alertTitle;
if (error) {
    alertMsg = error.localizedDescription;
    alertTitle = @"Error";
} else {
    NSDictionary *resultDict = (NSDictionary *)result;
    alertMsg = [NSString stringWithFormat:@"Successfully posted '%@'.\nPost ID: %@",
                message, [resultDict valueForKey:@"id"]];
    alertTitle = @"Success";

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:alertTitle
[alertView show];

The odd thing is, this code works ONCE. After authenticating the user for the first time, I can post ONE status update successfully. After that, all subsequent attempts will fail with a FBiOSSDK error 5 (in the console, Error: HTTP status code:400). The only way to fix this is to remove the app from the facebook account and re-authenticate. I'm not sure what the problem is. I looked online for solutions but couldn't find anything. If anyone knows how to fix this, please let me know. Thanks

asked Sep 7, 2015 by rajesh
0 votes

Related Hot Questions

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.