English 中文(简体)
Facebook SDK + SDK + SSO
原标题:Facebook SDK + iPhone SDK + SSO

我知道,有人问这个问题,但我每天都在读过,运用了我能够发现和仍然有问题的整套办法。

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: enter image description here

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

问题回答

确保你的“Facebook”申请(你在Facebook上设定的实际应用)不采用沙箱方式,如果能够确保用户“Facebook”应用程序(Pebook客户)目前与这一应用程序的开发商挂在一起。





相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签