Why can't I access the facebook friends list after reopening a session in ios
Posted
by
user1532390
on Stack Overflow
See other posts from Stack Overflow
or by user1532390
Published on 2012-11-20T22:35:00Z
Indexed on
2012/11/20
23:01 UTC
Read the original article
Hit count: 279
I am upgrading to the facebook 3.0 sdk for ios. Things went well, until I tried to open an existing session after relaunching the application. I am trying to access the list of friends for the facebook user.
if ([[FBSession activeSession] isOpen]) {
[request startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
//do something here
}];
}else{
[[self session] openWithCompletionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
if ([self isValid]) {
[request startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
//log this error we always get
NSLog(@"%@",error);
//do something else
}];
}
}];
}
However I get this error:
Error Domain=com.facebook.sdk Code=5 "The operation couldn’t be completed. (com.facebook.sdk error 5.)" UserInfo=0x1d92ff40 {com.facebook.sdk:ParsedJSONResponseKey={
body = {
error = {
code = 2500;
message = "An active access token must be used to query information about the current user.";
type = OAuthException;
};
};
code = 400;
}, com.facebook.sdk:HTTPStatusCode=400}
I've found that if I use the FBSession reauthorize method it allows me to complete the request without error, but it also means I must show UI or switch apps every time we relaunch the application which is unacceptable. Any suggestions on what I should be doing differently?
© Stack Overflow or respective owner