Alrighty. I have a button (below) where I take some info from an app and I post it to the users FB feed.
It almost never works the first time. Them, it will usually work pretty well after that. What happens is, when I press the button it tells me that I already gave the app permission to use FB (which I would like to only have to see the first time, not every time). Then when I press OK from there it will either go back to the app, or it will go to show me the page where I can actually post to my wall (which is what I want).
Im trying different things to get this to work more consistently. Is there something here that would be causing this behavior?
-(IBAction)fbButton:(id)sender {
if (![facebook isSessionValid]) {
[facebook authorize:permissions];
[permissions release];
}
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:@"FBAccessTokenKey"]
&& [defaults objectForKey:@"FBExpirationDateKey"]) {
facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
}
//Post to Wall
NSString *poopDollas = [[NSString alloc] initWithFormat:
@"sometext $%@!",dollas.text];
SBJSON *jsonWriter = [[SBJSON new] autorelease];
// The action links to be shown with the post in the feed
NSArray* actionLinks = [NSArray arrayWithObjects:[NSDictionary dictionaryWithObjectsAndKeys:
@"Get Started",@"name",@"http://www.facebook.com/pages/xx/204640386498567",@"link", nil], nil];
NSString *actionLinksStr = [jsonWriter stringWithObject:actionLinks];
// Dialog parameters
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"DM", @"name",
poopDollas, @"caption",
@"sometext", @"description",
@"http://www.facebook.com/pages/xx/204640386498567", @"link",
@"http://farm8.staticflickr.com/7185/6999841878_e66a8e00fc_t.jpg", @"picture",
actionLinksStr, @"actions",
nil];
FBDialog *delegate = (FBDialog *)[UIApplication sharedApplication].delegate;
[facebook dialog:@"feed" andParams:params andDelegate:(id <FBDialogDelegate>)delegate];
}