1

我使用 facebook 集成我的一个 iOS 应用程序,它共享报价。但问题是,当我的时间轴上引用帖子时,我的朋友们无法分享“喜欢”和“评论”。我想分享以请查看附加屏幕截图,所以最好的解决方案是我的 FB 应用程序中存在问题,或者我必须在 iOS 中为此编写代码。

FB截图

提前致谢

4

1 回答 1

0

我检查了你的截图。这基本上看起来像fb“像帖子”。因为没有人可以分享这篇文章。我建议您使用最新的 ios fb sdk 3.1.1,然后将该 FB sdk 与您的 ios 应用程序集成。然后使用下面的代码

对于 ios 6 及更高版本,请使用 ios 6 原生 fb post 方法:

if(NSClassFromString(@"SLComposeViewController") != nil) {

        UIApplication* app = [UIApplication sharedApplication];
        app.networkActivityIndicatorVisible = NO;

        SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

        SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result){
            if (result == SLComposeViewControllerResultCancelled) {

                NSLog(@"\nCancelled");                
            } else
            {
                NSLog(@"\nDone");
            }

            [controller dismissViewControllerAnimated:YES completion:Nil];
        };
        controller.completionHandler =myBlock;

        [controller setInitialText:FB_POST_FEED_INITIAL_TEXT_MSG];
        [controller addURL:[NSURL URLWithString:BITLY_VIEW_LINK]]; // youtube video link

        [self presentViewController:controller animated:YES completion:Nil];
}

否则使用这个 FB sdk 方法:

    [FBSession openActiveSessionWithReadPermissions:nil
                                       allowLoginUI:YES
                                  completionHandler:
     ^(FBSession *session,
       FBSessionState state, NSError *error) {
         switch (state) {
             case FBSessionStateOpen:
                 //first shows the hud view then initiating the post message feed process
                 [self postFBMessageOnUserWall];
                  break;
             case FBSessionStateClosed:
                 //need to handle
                 break;
             case FBSessionStateClosedLoginFailed:
                 //need to handle
                 break;
             default:
                 break;
         }
     }];


-(void)postFBMessageOnUserWall {
    NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
                             FB_POST_FEED_INITIAL_TEXT_MSG, @"name", BITLY_VIEW_LINK, @"link", nil];

     [FBRequestConnection
      startWithGraphPath:@"me/feed"
      parameters:params
      HTTPMethod:@"POST"
      completionHandler:^(FBRequestConnection *connection,
                          id result,
                          NSError *error) {

          //show the alert says that message successfully posted in your wall
          [self performSelectorOnMainThread:@selector(showAlertFromMainThread:) withObject:error waitUntilDone:NO];

          NSLog(@"\n\nfb post feed error status  = %@", error);
      }];
}
于 2013-02-08T19:19:54.440 回答