Retrieving user information from Facebook using the graphical API

I want to get basic user information from Facebook, but have some problems in the following code

-(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]; }** } } 

In firstMatch, I get NULL, so [_delegate accessTokenFound: accessToken]; these methods are not called.

Can someone please help me so that I can receive information from Facebook

Thanks in advance.

+6
source share
1 answer

Call the fbdid login method after initializing it with the application identifier and credentials.

 (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; } 

}

+3
source

Source: https://habr.com/ru/post/915897/


All Articles