2013-08-02 61 views
1

请参阅12月29日更新的笔记在页面底部时画布URL错误。的iOS:张贴到墙上

您好我正在做其他人的iOS项目工作(这是一种灵魂破坏,因为他们没有记录他们的代码)maintanance工作。

的问题是,用户登录后,试图分享讯息到墙上总是导致

错误100:“帖子的链接必须直接到应用程序的连接或帆布URL”。

我搜索在过去的2小时,适用于iOS还没有找到任何结果明确(但很多WordPress的,这并没有帮助)

任何想法可能会导致此。

这里张贴在墙上的海外开发人员代码:

-(void)uploadPropertyDetailsOnFacebookWall 
{ 


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

NSString* photoURL = @""; 
NSString *[email protected]""; 
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,任何额外paramater除了“消息”,崩溃的应用程序。

  • 我也尝试应用与其他堆栈溢出的用户建议的设置链接到一个测试帐户viewable here

  • 我也禁用后流安全

其他问题

  • 我错过了将应用程序连接到Facebook的东西吗?
  • 为什么不会它检测到“链接”参数是一样的帆布网址是什么?

回答

1

我一直在挣扎张贴到Facebook涂鸦墙了。

为什么不使用facebook SDK而不是API? 有两种方式发布到Facebook涂鸦墙使用SDK

通过Feed Dialog 或 通过Share Dialog

饲料对话是很容易实现,你可以控制你想通过你发送的参数作什么岗位,唯一不好的是参数是有限的。

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

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

编辑

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]; 

       } 

      } 

     } 

    }]; 
+0

我没有获得饲料对话,代码使用SDK 3.1.1 –

+0

我Eddited与我使用一些代码的aswer。检查是否可以更新sdk,尽管我相信Feed对话框在该版本中可用。 –