gpt4 book ai didi

iphone - 使用图形 API 从 Facebook 获取用户信息

转载 作者:行者123 更新时间:2023-11-30 05:22:34 26 4
gpt4 key购买 nike

我想从 Facebook 获取基本的用户信息,但是在下面的代码中遇到了一些问题

-(void)checkForAccessToken:(NSString *)urlString {
NSError *error;
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"access_token=(.*)&" options:0 error:&error];
if (regex != nil) {
**NSTextCheckingResult *firstMatch = [regex firstMatchInString:urlString options:0 range:NSMakeRange(0, [urlString length])];
if (firstMatch) {
NSRange accessTokenRange = [firstMatch rangeAtIndex:1];
NSString *accessToken = [urlString substringWithRange:accessTokenRange];
accessToken = [accessToken stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[_delegate accessTokenFound:accessToken];
}**
}
}

在 firstMatch 中我得到 NULL 这就是为什么 [_delegate accessTokenFound:accessToken];这个方法不会被调用。

任何人都可以帮助我,以便我能够从 Facebook 获取用户信息

提前致谢。

最佳答案

在使用应用程序 ID 和凭据初始化后调用 fbdid 登录方法。-

(void)fbDidLogin {

NSLog(@"fbDidLogin");
isFacebookLoaded=YES;


NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[facebook accessToken] forKey:@"FBAccessTokenKey"];
[defaults setObject:[facebook expirationDate] forKey:@"FBExpirationDateKey"];
[defaults synchronize];
NSLog(@"i am in and my acees token is %@ %@ and call me.CALLshowAloadingView",[facebook accessToken],[facebook expirationDate]) ;
[self.facebook requestWithGraphPath:@"me" andDelegate:self];
if ( [delegate respondsToSelector:@selector(showAloadingView)] )
{
NSLog(@" CALLshowAloadingView");
// calling delegate method. For this method to function, the delegate should be implemented in the calling class.
[delegate showAloadingView];
}


// Inform the delegate that Login is successful
if ( [delegate respondsToSelector:@selector(loginStatus:)] ) {
// calling delegate method. For this method to function, the delegate should be implemented in the calling class.
[delegate loginStatus:YES];
return;
}

关于iphone - 使用图形 API 从 Facebook 获取用户信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10616426/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com