0

FB リクエストの出力が iOS で機能しません。コンソールに2回出力します。初めて正しい情報を出力し、すぐに正しいデータの代わりに (null) を使用して同じことを行います。

ここに私のコードがあります:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{

facebook = [[Facebook alloc] initWithAppId:@"fbKEY....." andDelegate:self];

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:@"FBAccessTokenKey"] 
    && [defaults objectForKey:@"FBExpirationDateKey"]) {
    facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
    facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
}

//FB check for valid session


if (![facebook isSessionValid]) {
    NSArray *permissions = [[NSArray alloc] initWithObjects:
                            @"user_likes", 
                            @"read_stream",
                            @"user_location",
                            @"user_checkins",
                            //    @"publish_actions",
                            //    @"user_activities",
                            //    @"friends_birthday",
                            nil];

    [facebook authorize:permissions];

}


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


// get the posts made by the "platform" page
[facebook requestWithGraphPath:@"platform/posts" andDelegate:self];

// get the logged-in user's friends
[facebook requestWithGraphPath:@"me/friends" andDelegate:self];

[facebook dialog:@"feed" andDelegate:self];

// Override point for customization after application launch.
return YES;

}

- (void)request:(FBRequest *)request didLoad:(id)result { 

NSDictionary *userData = (NSDictionary *)result; // The result is a dictionary

NSString *name = [userData objectForKey:@"name"];
NSString *location = [[userData objectForKey:@"location"] objectForKey:@"name"];
NSString *gender = [userData objectForKey:@"gender"];

NSLog(@"name is %@", name);
NSLog(@"location is %@", location);

NSLog(@"gender is %@", gender);

// NSLog(@"%@",result); 

}

ここに私の NSLog 出力があります:

2012-04-04 16:42:56.440 Whatto[86350:15803] name is John Doe
2012-04-04 16:42:56.441 appName[86350:15803] location is London
2012-04-04 16:42:56.441 appName[86350:15803] gender is male
2012-04-04 16:42:56.688 appName[86350:15803] name is (null)
2012-04-04 16:42:56.688 appName[86350:15803] location is (null)
2012-04-04 16:42:56.689 appName[86350:15803] gender is (null)
2012-04-04 16:42:58.696 appName[86350:15803] name is (null)
2012-04-04 16:42:58.697 appName[86350:15803] location is (null)
2012-04-04 16:42:58.697 appName[86350:15803] gender is (null)

助けてくれてありがとう

4

1 に答える 1

1

3 つの異なるリクエストを作成し、すべての回答がユーザーであるかのように結果を処理しています... 2 番目の結果は投稿のリストになり、3 番目の結果は友達のリストになります。

幸運を!

于 2012-04-04T16:02:52.067 に答える