I want to share my details in the application. I just did the same as in the facebook tutorial. When the login page and dialog appears, and I sent my msg.and, it worked fine only the first time. When the user clicked the button again, a dialog box will appear and show the error page
"Error occurred with 'Your_APP_NAME'.please try again later."
I followed the tutorial in the facebook link below. https://developers.facebook.com/docs/mobile/ios/build/
Here is my code.
-(void)buttonPressed:(id)sender{
facebook = [[Facebook alloc] initWithAppId:@"YOUR_APP_ID" andDelegate:self];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:@"FBAccessTokenKey"] && [defaults objectForKey:@"FBExpirationDateKey"]) {
facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
}
if (![facebook isSessionValid]) {
[facebook authorize:nil];
}else{
[self postWall];
}
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
return [facebook handleOpenURL:url];
}
- (void)fbDidLogin {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[facebook accessToken] forKey:@"FBAccessTokenKey"];
[defaults setObject:[facebook expirationDate] forKey:@"FBExpirationDateKey"];
[defaults synchronize];
[self postWall];
}
-(void)postWall{
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
kAppId,@"app_id",
@"https://developers.facebook.com/docs/reference/dialogs/",@"link",
@"http://fbrell.com/f8.jpg",@"picture",
@"Facebook Dialogs",@"name",
@"Reference Documentation",@"caption",
@"Using Dialogs to interact with users.",@"description",
@"Facebook Dialogs are so easy!",@"message",
nil];
[[self facebook] dialog:@"feed" andParams:params andDelegate:self];
}
I am doing all this code in a viewcontroller file (not in application delegation). I want to open facebook only when I press the button. Therefore, I put these encodings in my pressed method.