为邀请朋友设置facebook app

时间:2013-10-10 11:43:24

标签: ios facebook cocoa-touch facebook-graph-api facebook-invite-friends

这可能是一个简单的问题,但我已经厌倦了

Facebook应用程序(我们在Facebook开发人员网站上创建应用程序时设置)是否有任何设置可以让“邀请朋友”功能正常工作。

我正在使用WebDialog方法,如下所示,

FBWebDialogs presentRequestsDialogModallyWithSession:nil                                                   消息:FacebookInviteMessage                                                     标题:@“邀请朋友”                                                参数:参数                                                   handler:^(FBWebDialogResult结果,NSURL * resultURL,NSError *错误)

使用相同的方法,当我在项目中使用另一个示例代码的Facebook APP ID时,我可以邀请朋友。但是当我使用自己项目的Facebook APP ID时,如果我在结果网址中获得成功,则邀请无效。

所以我认为Facebook的开发者网站会有一些设置。

任何人都可以为此提供帮助

完整的代码是

NSDictionary *parameters = self.fbidSelection ? @{@"to":self.fbidSelection} : nil;


MIDLog(@"self.fbidSelection %@",self.fbidSelection);

[FBWebDialogs presentRequestsDialogModallyWithSession:nil
                                              message:FacebookInviteMessage
                                                title:@"Invite Friends"
                                           parameters:parameters
                                              handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {

                                                  NSString *strResultUrl = [resultURL absoluteString];

                                                  if (result == FBWebDialogResultDialogCompleted && ![strResultUrl isEqualToString:@"fbconnect://success"])
                                                  {
                                                      MIDLog(@"Web dialog complete: %@", resultURL);

                                                      if (![resultURL query])
                                                      {
                                                          return;
                                                      }

                                                      NSDictionary *params = [self parseURLParams:[resultURL query]];
                                                      NSMutableArray *recipientIDs = [[NSMutableArray alloc] init];
                                                      for (NSString *paramKey in params)
                                                      {
                                                          if ([paramKey hasPrefix:@"to["])
                                                          {
                                                              [recipientIDs addObject:[params objectForKey:paramKey]];
                                                          }
                                                      }
                                                      if ([params objectForKey:@"request"])
                                                      {
                                                          NSLog(@"Request ID: %@", [params objectForKey:@"request"]);
                                                      }
                                                      if ([recipientIDs count] > 0)
                                                      {
                                                          //[self showMessage:@"Sent request successfully."];
                                                          //NSLog(@"Recipient ID(s): %@", recipientIDs);
                                                          UIAlertView *alrt = [[UIAlertView alloc] initWithTitle:@"Success!" message:@"Invitation(s) sent successfuly!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
                                                          [alrt show];
                                                          alrt = nil;
                                                      }





                                                      UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Success" message:FacebookInviteSuccess delegate:self cancelButtonTitle:@"Proceed" otherButtonTitles:nil];
                                                      alert.tag = 14114;
                                                      [alert show];
                                                      alert = nil;

                                                      //                                                          [self navigateToSearch];
                                                  }

                                                  else if (result == FBWebDialogResultDialogCompleted && [strResultUrl isEqualToString:@"fbconnect://success"])
                                                  {
                                                      MIDLog(@"Cancel Clicked");

                                                      UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Cancelled" message:nil delegate:self cancelButtonTitle:@"Proceed" otherButtonTitles:nil];
                                                      alert.tag = 14114;
                                                      [alert show];
                                                      alert = nil;

                                                  }

                                                  else {
                                                      MIDLog(@"Web dialog not complete, error: %@", error.description);

                                                      UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:InternetFailError delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
                                                      alert.tag = 15115;
                                                      [alert show];
                                                      alert = nil;

                                                  }
                                              }
                                          friendCache:self.friendCache];

}

谢谢

0 个答案:

没有答案
相关问题