6

chcę uzyskać podstawowe informacje o użytkowniku z Facebooku, ale mając jakiś problem w poniższym kodzieUzyskiwanie informacji o użytkownikach z Facebook za pomocą wykresu API

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

W firstMatch jestem coraz NULL dlatego [_delegate accessTokenFound: accessToken ]; te metody nie są wywoływane.

Czy ktoś może mi pomóc tak, że będę mógł informacji użytkownika z Facebook

Dzięki z góry.

+0

Używasz Facebook SDK? Dlaczego chcesz zdobyć token dostępu w ten sposób zamiast używać oficjalnego interfejsu API Graph? – vinzenzweber

+0

Zwykle potrzebujesz tylko postąpić zgodnie z sugestiami w podręcznikach dev na Facebooku: https://developers.facebook.com/docs/mobile/ios/build/#graph – vinzenzweber

Odpowiedz

3

Wywołać fbdid metoda logowania po inicjalizacji go z identyfikatora aplikacji i 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; 
} 

}

Powiązane problemy