首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在我的iPhone集成Facebook应用程序中,但是当我在我的墙上发帖时,我的朋友无法分享,我该怎么办?

在我的iPhone集成Facebook应用程序中,但是当我在我的墙上发帖时,我的朋友无法分享,我该怎么办?
EN

Stack Overflow用户
提问于 2012-05-25 15:01:44
回答 1查看 178关注 0票数 1

我使用facebook integrate为我的一个iOS应用程序,它分享报价。但问题是,当在我的时间线上引用帖子时,我的朋友不能只分享“喜欢”和“评论”。我想分享,请看附件截图,所以什么是最好的解决方案,是在我的FB应用程序中有问题,还是我必须为此在iOS中的代码。

Screenshot of FB

提前感谢

EN

回答 1

Stack Overflow用户

发布于 2013-02-09 03:19:54

我看了你的截图。这看起来像fb“就像帖子”。因为没有人不能分享这篇文章。我建议你使用最新的ios fb sdk 3.1.1,然后将FB sdk集成到你的ios应用程序中。然后使用以下代码

对于ios 6和更高版本,请使用ios 6本机fb post方法:

代码语言:javascript
复制
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方法:

代码语言:javascript
复制
    [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);
      }];
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10749928

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档