iOS:发布到墙上时出现 Canvas URL 错误

标签 ios facebook facebook-wall

请参阅页面底部的 12 月 29 日更新说明。

您好,我正在工作中为其他人的 iOS 项目做维护工作(这有点令人心碎,因为他们没有记录他们的代码)。

问题是在用户登录后,尝试将帖子分享到墙上总是会导致

错误 100:“帖子的链接必须指向应用程序的连接或 Canvas URL”。

我搜索了过去 2 个小时,但没有找到任何专门针对 iOS 的结果(但有很多 wordpress 的结果,但没有帮助)

任何可能导致此问题的想法。

贴墙的海外开发者代码如下:

-(void)uploadPropertyDetailsOnFacebookWall
{


[FBSettings setLoggingBehavior:[NSSet setWithObjects:FBLoggingBehaviorFBRequests, FBLoggingBehaviorFBURLConnections, nil]];

NSString* photoURL = @"";
NSString *strFullPropertyDetailLink=@"";
if (!kIsListOnce) {
    photoURL = [currentItem objectForKey:@"Photo1FeaturedURL"];
    strFullPropertyDetailLink=[currentItem objectForKey:@"FullDisplayLink"];
}
else {
    strFullPropertyDetailLink=[currentItem objectForKey:@"FullDisplayLink"];
    NSArray* list = [[currentItem objectForKey:@"objects"] objectForKey:@"img_small"];
    ;
    if ([list count] > 0) {
        photoURL = [list objectAtIndex:0];
    }

}

[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;

NSString *strLinkOfApp=(NSString *)[Utils config:KiTunesstoreAppLink]; //strFullPropertyDetailLink,
NSDictionary *postParams =
[[NSMutableDictionary alloc] initWithObjectsAndKeys:


 strFullPropertyDetailLink, @"link",
 photoURL, @"picture",
 [Utils config:kTextAgentName], @"name",
 strAddress, @"caption",
 [currentItem objectForKey:@"Description"], @"description",
 nil];



[FBRequestConnection startWithGraphPath:@"me/feed"
                             parameters:postParams
                             HTTPMethod:@"POST"
                      completionHandler:^(FBRequestConnection *connection,
                                          id result,
                                          NSError *error)
 {
     [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;

     NSString *alertText;

     NSLog(@"%@",error);


     if (error) {

         NSDictionary *dict=[error userInfo];
         NSLog(@"%@",dict);

         NSDictionary *dictJSON=[dict objectForKey:@"com.facebook.sdk:ParsedJSONResponseKey"];
         NSDictionary *dictBody=[dictJSON objectForKey:@"body"];
         NSDictionary *dictError=[dictBody objectForKey:@"error"];

         NSString *strCode=[[dictError objectForKey:@"code"] description];

         if([strCode isEqualToString:@"200"])
         {
             alertText = @"You have not authorized the application to perform this publish action";
         }else{
         alertText = [@"An error ocurred: " stringByAppendingString:error.description];
             alertText=[alertText stringByAppendingString: strFullPropertyDetailLink];
         }
     } else {
         alertText = [NSString stringWithFormat:
                      @"Property details has been successfully shared on your Facebook Wall"];

     }
     [[[UIAlertView alloc] initWithTitle:@"Result"
                                 message:alertText
                                delegate:nil
                       cancelButtonTitle:@"OK!"
                       otherButtonTitles:nil] show];
     // Show the result in an alert

 }];

}

这是我不断收到的错误:

Error Domain=com.facebook.sdk Code=5 "The operation couldn’t be completed(com.facebook.sdk                  error 5.)" UserInfo=0x1d548710 {com.facebook.sdk:ParsedJSONResponseKey={
body =     {
    error =         {
        code = 100;
        message = "(#100) The post's links must direct to the application's connect or canvas URL.";
        type = OAuthException;
    };
};
code = 400;
}, com.facebook.sdk:HTTPStatusCode=400}
2013-08-02 12:06:12.806 RealEstate[385:907] {
"com.facebook.sdk:HTTPStatusCode" = 400;
"com.facebook.sdk:ParsedJSONResponseKey" =     {
    body =         {
        error =             {
            code = 100;
            message = "(#100) The post's links must direct to the application's connect or canvas URL.";
            type = OAuthException;
        };
    };
    code = 400;
};
}

请帮忙,自从我最初发帖以来,我在网上做了更多的研究,但仍然找不到答案。

12 月 17 日更新:

  • 我使用的是 SDK 3.1.1。我想避免必须更新,因为我正在维护其他人的代码。

  • 在 fbrequestconnection 中使用 me/feed,除了“消息”之外的任何其他参数都会导致应用程序崩溃。

  • 我还尝试将应用程序链接到测试帐户,并使用其他 stack overflow 用户建议的设置 viewable here

  • 我还禁用了流后安全

其他问题

  • 在将应用程序链接到 Facebook 时我是否遗漏了什么?
  • 为什么它检测不到“链接”参数与 Canvas url 相同?

最佳答案

我也一直在努力发帖到 facebook 墙上。

为什么不使用 facebook SDK 而不是 API? 有两种使用SDK发帖到facebook墙的方法

通过Feed Dialog 或者 通过Share Dialog

Feed Dialog很容易实现,你可以通过你发送的参数来控制你想发布什么,唯一不好的是参数是有限的。

Share Dialog 使用 OpenGraph 并要求用户安装 facebook APP,您还必须在 facebook 的应用开发者页面中创建一个操作,以便您的应用知道如何处理该操作。 好处是您几乎可以分享所有想要的东西。

如果你想要一个简单的 facebook 分享,我建议你检查 Feed Dialog,这是最简单的方法。

编辑

    NSString *message = [NSString stringWithFormat:@"%@%@/%@",domain,TypeName,[object alias]];

    // Put together the dialog parameters

    NSMutableDictionary *params =

    [NSMutableDictionary dictionaryWithObjectsAndKeys:

     @"TITLE", @"description",

     message, @"link",

     [object image],@"picture",

     nil];

    // Invoke the dialog

    [FBWebDialogs presentFeedDialogModallyWithSession:nil

                                       parameters:params

                                          handler:

     ^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {

         if (error) {

         // Error launching the dialog or publishing a story.

         //NSLog(@"Error publishing story.");

         } else {

             if (result == FBWebDialogResultDialogNotCompleted) {

                 // User clicked the "x" icon

                 //NSLog(@"User canceled story publishing.");

             } else {

                 // Handle the publish feed callback

                 NSDictionary *urlParams = [self parseURLParams:[resultURL query]];

                 if (![urlParams valueForKey:@"post_id"]) {

                     // User clicked the Cancel button

                     //NSLog(@"User canceled story publishing.");

                 } else {

                     // User clicked the Share button

                     NSString *msg = @"Partilhado com sucesso";

                     //NSLog(@"%@", msg);

                     // Show the result in an alert

                     [[[UIAlertView alloc] initWithTitle:@"Aviso"

                                                 message:msg

                                                delegate:nil

                                       cancelButtonTitle:@"OK!"

                                       otherButtonTitles:nil]

                      show];

                 }

             }

         }

     }];

关于iOS:发布到墙上时出现 Canvas URL 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18007922/

相关文章:

ios - UICollection View 流布局垂直对齐

objective-c - 触摸详细信息披露指示器时 Mapview 注释崩溃

ios - Facebook iOS SDK : refreshing an expired access token without presenting a dialog

facebook - 有没有办法将 @mention 插入到使用 pyfacebook 发布的 Facebook 状态更新中?

facebook - 是否可以将 Facebook 提要发送到我属于但不拥有的封闭组?

javascript - 如何为 ios 应用程序 obj-c 创建 javascript 接口(interface)?

ios - 'userNotificationCenter :didReceiveNotificationResponse 实现中的参数类型冲突

ios - 我如何应对 Facebook API Graph 弃用警告?

ios - 如何在 ios sdk 3.2 之后从 ios 或 android 应用程序邀请所有 facebook 好友

asp.net - 使用 ASP.Net 的 Facebook Wall 功能