我想将 disqus 添加到我的 android 应用程序中。我跟踪并找到了显示带有 id 和短名称的 disqus 评论的代码。但是我找不到用于添加密钥和公钥的文档。然后往前走。
已经在 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?
Run Code Online (Sandbox Code Playgroud)
小智 5
@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>";
}
Run Code Online (Sandbox Code Playgroud)
瞧!
| 归档时间: |
|
| 查看次数: |
3968 次 |
| 最近记录: |