0

我目前的 iOS 应用程序有问题,因为我似乎无法向人们发送请求......这是我拥有的代码:

NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:nil];

if([FBSession activeSession].isOpen) {
    [FBWebDialogs presentRequestsDialogModallyWithSession:[FBSession activeSession] message:@"Join me." title:@"Invite" parameters:params handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
        NSLog(@"%@", [FBSession activeSession]);
        if (error)
            NSLog(@"Error sending request.");
        else {
            if (result == FBWebDialogResultDialogNotCompleted)
                NSLog(@"User canceled request.");
            else if(result == FBWebDialogResultDialogCompleted)
                NSLog(@"Request: %@", resultURL);
            else
                NSLog(@"Error unknown.");
        }
    }];        
}
else {
    [FBSession openActiveSessionWithReadPermissions:@[@"email"] allowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
        if(session.isOpen) {
            [FBSession openActiveSessionWithPublishPermissions:@[@"publish_actions"] defaultAudience:FBSessionDefaultAudienceEveryone allowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
                if(session.isOpen) {
                    [self showRequestForFacebook];
                }
            }];
        }
    }];
}

每次我得到一个Request: (null). 我得到了一个请求 ID,但帐户上什么也没有。我查看了 Facebook SDK 中的示例,似乎完全一样。但是,它适用于示例而不是我的代码。有什么地方可以改变吗?是developers.facebook.com上的东西吗?

编辑:我忘了说,在同一个应用程序中,我使用 SLComposeViewController 在 Facebook 上分享,它运行良好。

非常感谢!:)

4

1 回答 1

0
  NSString *query2 = [NSString stringWithFormat:@"SELECT uid, name, pic_square,is_app_user FROM user WHERE  is_app_user = 1 AND uid IN " @"(SELECT uid2 FROM friend WHERE uid1 = me())"];

// Set up the query parameter
NSDictionary *queryParam2 = @{ @"q": query2 };
// Make the API request that uses FQL
[FBRequestConnection startWithGraphPath:@"/fql" parameters:queryParam2  HTTPMethod:@"GET"
                                            completionHandler:^(FBRequestConnection *connection,
                                                               id result,
                                                               NSError *error)
                                           {

                                            if (error) {

                                            } else {
                                            // NSLog(@"Result: %@", result);
                                             // Get the friend data to display
                                             NSArray *friendInfo = (NSArray *) result[@"data"];
                                              NSLog(@"%@",friendInfo);
                                             self.data=friendInfo;

                                           [self constructDictionaryOfNumbers];
                                             // Show the friend details display

                                            }
                                           }];

}

于 2014-01-25T10:30:47.333 回答