简体   繁体   English

iOS-无法发送Facebook请求

[英]iOS - Can't send Facebook requests

I currently have a problem with my iOS application because I don't seem to be able to send requests to people... Here is the code that I have: 我的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];
                }
            }];
        }
    }];
}

Every time I get a Request: (null) . 每当我收到Request: (null) I get a request ID but nothing on the account. 我得到一个请求ID,但帐户上没有任何信息。 I looked at the sample in the Facebook SDK and I seem to have exactly the same. 我查看了Facebook SDK中的示例,似乎完全一样。 However, it works with the sample and not with my code. 但是,它适用于示例而不适用于我的代码。 Is there anything to change somewhere? 有什么地方可以改变吗? Is it something on developers.facebook.com? 在developers.facebook.com上有东西吗?

Edit: I forgot to say that in the same application I use a SLComposeViewController to share on Facebook and it works perfectly. 编辑:我忘了说在同一应用程序中,我使用SLComposeViewController在Facebook上共享它,并且效果很好。

Thanks a lot! 非常感谢! :) :)

  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

                                            }
                                           }];

} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM