我想将 disqus 添加到我的 android 应用程序中。 我追踪并找到了显示带有 id 和短名称的 disqus 评论的代码。 但是我找不到添加 key 和公钥的文件。然后继续前进。
已经在 Disqus 注册了,得到了我的私钥和公钥。 现在我需要知道,
1. Where to add the keys to the app.
2. How do I create id mapping to a particular page(activity/fragment).
3. Where am I supposed to give the short name?
最佳答案
@ndgreen,不再工作了!跨域安全提供加载外部JS。我们现在必须这样做:
String htmlComments = getHtmlComment("idPost", "youriddisqus");
yourWebView.loadDataWithBaseURL("http://youriddisqus.disqus.com/", htmlComments, "text/html", "UTF-8", "");
public String getHtmlComment(String idPost, String shortName) {
return "<html><head></head><body><div id='disqus_thread'></div></body>"
+ "<script type='text/javascript'>"
+ "var disqus_identifier = '"
+ idPost
+ "';"
+ "var disqus_shortname = '"
+ shortName
+ "';"
+ " (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;"
+ "dsq.src = '/embed.js';"
+ "(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })();"
+ "</script></html>";
}
瞧!
关于android - 将 Disqus 集成到 Android 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22327809/