2

アプリでFacebookユーザーの名前を取得しようとしていますが、取得しています

{"error":{"message":"An active access token must be used to query information about the current user.","type":"OAuthException","code":2500}}

私のコードは:-

viewdidload

facebook = [[Facebook alloc] initWithAppId:@"233350100117670" andDelegate:self];    
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:@"FBAccessTokenKey"] && [defaults objectForKey:@"FBExpirationDateKey"])
{
    facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
    facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
}
NSArray *permissions =  [[NSArray arrayWithObjects:@"read_stream", @"publish_stream", @"offline_access",nil] retain];
[facebook authorize:permissions];

if (![facebook isSessionValid])
{
    [facebook authorize:nil];
}

その後:-

- (void)request:(FBRequest *)request didFailWithError:(NSError *)error
{
    NSLog(@"%@", [error localizedDescription]);
    NSLog(@"Err details: %@", [error description]);
}

- (void)request:(FBRequest*)request didLoadRawResponse:(NSData*)data
{
    NSString *response = [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding];
    NSLog(@"%@", response);
    [response release];
}

- (void) request:(FBRequest*)request didLoad:(id)result
{
    if ([result isKindOfClass:[NSDictionary class]])
    {
        NSString *email = [result objectForKey: @"email"];
        fbUserName = [result objectForKey: @"name"];
        NSString *facebookId = [result objectForKey: @"id"];
        NSString* title=[NSString stringWithFormat:@"%@ has won a gold medal on Olympedia quiz",fbUserName];
        NSMutableDictionary *params = 
        [NSMutableDictionary dictionaryWithObjectsAndKeys:title, @"name",@"Feed Dialogs of Olympedia.", @"caption",@"Check out Olmpedia Dialogs.", @"description",@"http://www.facebook.com/olympedia", @"link",@"http://bit.ly/PdpRSD", @"picture",nil];  
        [facebook dialog:@"feed" andParams:params andDelegate:self];
   }
}

そして共有ボタンをクリックすると:-

- (IBAction)shareOnFacebook:(id)sender
{
    NSLog(@"Posting message");

    [facebook requestWithGraphPath:@"me" andDelegate:self];
}

これを何時間も解決しようとしているので、助けてください。強いテキスト

4

0 に答える 0