When a Facebook dialog is created with code like this
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys: apiKey, @"api_key", nil];
[facebook dialog:@"stream.publish" andParams:params andDelegate:self];
is there the possibility to use sessions?
I succeeded in publishing a post on a user's post wall, but how allow the user to logout?
Moreover I obtain this error when I try to access to current user information.
{
error = {
message = "An active access token must be used to query information about the current user.";
type = OAuthException;
};
}
I create the Facebook object in viewDidLoad
_facebook = [[Facebook alloc] init];
I have a tableView. When the user clicks on an entry, an action sheet pops up with 3 choices
1 send an email
2 share on Facebook
3 log out from Facebook: it should be there only if the user is logged, however for the moment it's there and it works.
I use
[_facebook logout:self];
and moreover the method
- (void)fbDidLogout is called.
When the user clicks on "share on Facebook", this code is run
SBJSON *jsonWriter = [SBJSON new];
NSDictionary *actionLinks = [NSArray arrayWithObjects:
[NSDictionary dictionaryWithObjectsAndKeys:
@"Some text", @"text",
@"http://try.com",@"href", nil], nil];
NSString *actionLinksStr = [jsonWriter stringWithObject:actionLinks];
NSDictionary* attachment = [NSDictionary dictionaryWithObjectsAndKeys:
@"is using...", @"name",
@"It's an app….", @"caption",
@"Download!", @"description",
@"http://ituneslink", @"href",
nil];
NSString *attachmentStr = [jsonWriter stringWithObject:attachment];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
API_KEY, @"api_key",
@"Message", @"user_message_prompt",
actionLinksStr, @"action_links",
attachmentStr, @"attachment",nil];
[_facebook dialog:@"stream.publish" andParams:params andDelegate:self];
[jsonWriter release];
In viewDidLoad, I've also tried to use
_facebook.accessToken = [[NSUserDefaults standardUserDefaults] stringForKey:@"AccessToken"];
_facebook.expirationDate = (NSDate *) [[NSUserDefaults standardUserDefaults] objectForKey:@"ExpirationDate"];
_permissions = [[NSArray arrayWithObjects: @"read_stream", @"offline_access",nil] retain];
if ([_facebook isSessionValid] == NO) {
[_facebook authorize:API_KEY permissions:_permissions delegate:self];
}
putting in fbDidLogin:
[[NSUserDefaults standardUserDefaults] setObject:_facebook.accessToken forKey:@"AccessToken"];
[[NSUserDefaults standardUserDefaults] setObject:_facebook.expirationDate forKey:@"ExpirationDate"];
but fbDidLogin is never called.
EDIT
I resolved using the FB october api (while I've not found a solution with the november one).
Looks like it's a permissions issue, try:
[facebook setPermission:@"offline_access"];