简体   繁体   English

将Facebook评论添加到我的iOS应用

[英]Add Facebook comments to my iOS app

I am developing a content display app in which there is a table view and a corresponding detail view to display the html data in a web view. 我正在开发一个内容显示应用程序,其中有一个表格视图和一个相应的详细信息视图,以在Web视图中显示html数据。

I want to include facebook comments plugin, For that i have included the fb javascript sdk but the fb commnets are not loading in the web view. 我想包含Facebook评论插件,为此,我包含了fb javascript sdk,但fb commnets不在网络视图中加载。

I am not able to under stand the reason 我无法理解原因

here is my code for the fb sdk. 这是我的fb sdk代码。

<div id='fb-root'></div>
<script>
window.fbAsyncInit = function() { FB.init({ appId : 'xxxxxxxxxxxxx', xfbml : true, version : 'v2.1' }); };
(function(d, s, id) {
 var js, fjs = d.getElementsByTagName(s)[0];
 if (d.getElementById(id)) return;
 js = d.createElement(s); js.id = id;
 js.src = 'http://connect.facebook.net/en_US/sdk.js';
 fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class='fb-comments' data-href='http://xxxxx/xx/xx' data-numposts='5' data-colorscheme='light'></div>
It worked for me perfectly.

NSString *html =@"\
<!DOCTYPE html>\
<html>\
<head>\
</head>\
<body>\
<div id=\"fb-root\"></div>\
<script>(function(d, s, id) {\
var js, fjs = d.getElementsByTagName(s)[0];\
if (d.getElementById(id)) return;\
js = d.createElement(s); js.id = id;\
js.src = \"//connect.facebook.net/en_US/all.js#xfbml=1&appId=211241782359485\";\
fjs.parentNode.insertBefore(js, fjs);\
}(document, 'script', 'facebook-jssdk'));</script>\
<div class=\"fb-comments\" data-href=\"http://www.google.com\" data-width=\"470\"></div>\
</body>\
</html>\
";
[self.commentsWebView stopLoading];
[self.commentsWebView loadHTMLString:html baseURL:[NSURL URLWithString:@"http://www.google.com"]];    

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

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