简体   繁体   English

Facebook IOS SDK:“发布故事”对话框中的错误

[英]Facebook IOS SDK: Error in Publish Story Dialog

I've successfully set up the "DemoApp" project from the Facebook IOS SDK to use my "OKC ThunderCast" Facebook application. 我已经从Facebook IOS SDK成功设置了“ DemoApp”项目,以使用我的“ OKC ThunderCast” Facebook应用程序。 I have also configured another "Tester" application from scratch to successfully use the Facebook SDK and publish stories to my news feed. 我还从头开始配置了另一个“测试器”应用程序,以成功使用Facebook SDK并将故事发布到我的新闻提要中。 However, in my production application, I always get this result when calling the "dialog" method. 但是,在生产应用程序中,调用“对话框”方法时总是 会得到此结果 The full description of the error message is "Error on line 52 at column 17: Opening and ending tag mismatch: div line 0 and body" 错误消息的完整描述是“第17列第52行的错误:打开和结束标记不匹配:div第0行和正文”

Here's a detailed walkthrough of all of my code to make sure nothing is missed. 这是我所有代码的详细演练,以确保不会遗漏任何内容。

1) A UIViewController calls the "authorize" method 1)UIViewController调用“授权”方法

NSArray *fbPerms = [NSArray arrayWithObjects:@"read_stream", @"offline_access", nil];
[[FacebookSingleton sharedInstance].facebook authorize:fbPerms delegate:self];

Note: The FacebookSingleton is a class I wrote that always returns a single instance of the "Facebook" class. 注意:FacebookSingleton是我编写的一个类,该类始终返回“ Facebook”类的单个实例。 I am using it successfully in other applications. 我在其他应用程序中成功使用了它。

2) Safari is opened and the user is successfully authenticated and authorized 2)Safari已打开,并且用户已成功通过身份验证和授权

3) The application is called back and the "handleOpenUrl" method is called, which calls the "fbDidLogin" method of the UIViewController 3)调用该应用程序,并调用“ handleOpenUrl”方法,该方法调用UIViewController的“ fbDidLogin”方法

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
 {
Facebook *fb = [FacebookSingleton sharedInstance].facebook;
return [fb handleOpenURL:url];
 }

4) The same UIViewController handles the "fbDidLogin" event, and calls the "dialog" method 4)相同的UIViewController处理“ fbDidLogin”事件,并调用“ dialog”方法

- (void)fbDidLogin
{   
[[FacebookSingleton sharedInstance].facebook dialog:@"feed" andDelegate:self];
   }

I also have the necessary "URL Schemes" and "URL Types" entries in the .plist file. 我在.plist文件中也有必要的“ URL方案”和“ URL类型”条目。 To my eyes, I am using exactly the same code in the "DemoApp", "Tester", and production applications. 在我看来,我在“ DemoApp”,“ Tester”和生产应用程序中使用的代码完全相同。 But while the DemoApp and Tester work, I always see this HTML error in the feed dialog in my production application. 但是当DemoApp和Tester工作时,我总是在生产应用程序的feed对话框中看到此HTML错误。 Has anyone seen a similar issue? 有没有人看到过类似的问题? Could it be related to the Facebook "Bundle ID" setting in the Facebook application settings? 可能与Facebook应用程序设置中的Facebook“ Bundle ID”设置相关吗? Is there some build or .plist setting that is different? 是否有一些不同的build或.plist设置?

I have invested a great deal of time into troubleshooting with no success in several weeks. 我花了很多时间进行故障排除,但几周没有成功。 Thanks in advance... 提前致谢...

The cause of the problem was setting a value to the key "User-Agent" in the NSUserDefaults dictionary. 问题的原因是在NSUserDefaults字典中将值设置为键“ User-Agent”。 I wanted to specify my own User-Agent to uniquely identify my iOS app. 我想指定自己的User-Agent来唯一标识我的iOS应用。 But somehow setting this value caused the problem above. 但是以某种方式设置此值会导致上述问题。 When I simply renamed this key to "OKCTC-User-Agent" the error was immediately resolved. 当我简单地将此键重命名为“ OKCTC-User-Agent”时,该错误立即得到解决。

I did log an issue on the GitHub site for the Facebook-IOS-SDK . 我确实在GitHub站点上的Facebook-IOS-SDK上记录了一个问题 Hopefully this will help others who have encountered similar problems. 希望这会帮助遇到类似问题的其他人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM