我知道,有人问这个问题,但我每天都在读过,运用了我能够发现和仍然有问题的整套办法。
I am trying to implement Facebook SDK s new SSO feature to allow my app to authenticate with Facebook s app instead of a webView. When my app switches to Facebook s app, it says loading for a few seconds and switches back but the token is still null. I have a feeling it has to do with the URL scheme for my app but I have followed many tutorials and am fairly confident that my current plist values are correct:
Here is the code I have implemented in my appDelegate and viewController files: appDelegate.h
Facebook *facebook;
页: 1
// Pre 4.2 support
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
return [facebook handleOpenURL:url];
}
// For 4.2+ support
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [facebook handleOpenURL:url];
}
第二View。
-(IBAction) fbButton {
//FACEBOOK INTEGRATION
appDelegate.facebook = [[Facebook alloc] initWithAppId:@"222087841143437" andDelegate:appDelegate];
// Check and retrieve authorization information
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:@"FBAccessTokenKey"]
&& [defaults objectForKey:@"FBExpirationDateKey"]) {
appDelegate.facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
appDelegate.facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
}
if (![appDelegate.facebook isSessionValid]) {
appDelegate.facebook.sessionDelegate = self;
[appDelegate.facebook authorize:permissions];
NSLog(@"Token: %@", [defaults objectForKey:@"FBAccessTokenKey"]);
} else {
NSLog(@"Already logged in!");
}
[appDelegate.facebook requestWithGraphPath:@"me" andDelegate:self];
}
- (void)request:(FBRequest *)request didLoad:(id)result {
NSString *nameID = [[NSString alloc] initWithFormat:@"%@ (%@)", [result objectForKey:@"name"], [result objectForKey:@"id"]];
NSMutableArray *userData = [[NSMutableArray alloc] initWithObjects:
[NSDictionary dictionaryWithObjectsAndKeys:
[result objectForKey:@"id"], @"id",
nameID, @"name",
[result objectForKey:@"picture"], @"details",
nil], nil];
[userData release];
[nameID release];
NSLog(@"DATA RECEIVED: %@", result);
}
- (void)request:(FBRequest *)request didReceiveResponse:(NSURLResponse *)response {
NSLog(@"request:didReceiveResponse:");
}
- (void)request:(FBRequest *)request didFailWithError:(NSError *)error {
NSLog(@"%@", [error localizedDescription]);
NSLog(@"Err details: %@", [error description]);
};
- (void)fbDidLogin {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[[appDelegate facebook] accessToken] forKey:@"FBAccessTokenKey"];
[defaults setObject:[[appDelegate facebook] expirationDate] forKey:@"FBExpirationDateKey"];
[defaults synchronize];
NSLog(@"Facebook Logged in!");
[appDelegate.facebook requestWithGraphPath:@"me" andDelegate:self];
}
我知道我所说的话。 脸书要求With GraphPath:@“me”和Delegate:本人]两度,但我不认为这个问题。
当我向 log子报话时,这便是一个ole子:
2011-10-18 15:37:33.287 Track[2235:707] Token: (null)
2011-10-18 15:37:36.578 Track[2235:707] request:didReceiveResponse:
2011-10-18 15:37:36.584 Track[2235:707] The operation couldn’t be completed. (facebookErrDomain error 10000.)
2011-10-18 15:37:36.586 Track[2235:707] Err details: Error Domain=facebookErrDomain Code=10000 "The operation couldn’t be completed. (facebookErrDomain error 10000.)" UserInfo=0x1ce480 {error=<CFBasicHash 0x1c9560 [0x3e368630]>{type = mutable dict, count = 2,
entries =>
2 : <CFString 0x19a830 [0x3e368630]>{contents = "type"} = <CFString 0x11d230 [0x3e368630]>{contents = "OAuthException"}
3 : <CFString 0x1f5b60 [0x3e368630]>{contents = "message"} = <CFString 0x1f8a70 [0x3e368630]>{contents = "An active access token must be used to query information about the current user."}
我赞赏这一帮助,我确实希望,我没有错过在这里讨论这个问题。 下面是我读过的几个(其中许多人),在找到解决办法方面没有任何成功。
How to implement Single Sign On (SSO) using facebook ios sdk for iphone Facebook SSO and request iOS SDK Facebook API for iPhone Error: An active access token must be used