views:

31

answers:

1

I have an app that I want to be able to connect to Facebook and post to the user's wall. I have the following code:

  • (void)viewDidLoad { static NSString* kApiKey = @"PRIVATE"; static NSString* kApiSecret = @"PRIVATE"; _session = [[FBSession sessionForApplication:kApiKey secret:kApiSecret delegate:self] retain];

    // Load a previous session from disk if available. Note this will call session:didLogin if a valid session exists. [_session resume]; // Set these values from your application page on http://www.facebook.com/developers // Keep in mind that this method is not as secure as using the sessionForApplication:getSessionProxy:delegate method! // These values are from a dummy facebook app I made called MyGrades - feel free to play around!

    [super viewDidLoad]; }

  • (IBAction)postGradesTapped:(id)sender { _posting = YES; // If we're not logged in, log in first... if (![_session isConnected]) { self.loginDialog = nil; _loginDialog = [[FBLoginDialog alloc] init]; [_loginDialog show]; } // If we have a session and a name, post to the wall! else if (_facebookName != nil) { [self postToWall]; } // Otherwise, we don't have a name yet, just wait for that to come through. }

The problem I have is that when the user clicks the button associated with the IBAction it will pop up the login dialog, but then the window disappears without ever pulling up the Publish Story to Wall dialog. How do I get it to login and then pull up the Publish Story to Wall?

A: 

I think you may need to use FBPermissionDialog to ask for "post to wall" permission first (I'm not sure what the exact string is; it might be in the examples).

Also note that "FBSession" is the old "iPhone" SDK (last updated in April); there's a newer "iOS" SDK at http://github.com/facebook/facebook-ios-sdk

tc.
I thought of that, but if I close the app and restart it without logging out from Facebook, and then click the button, it will open up the Publish Story to Wall dialog.
Tyler