【问题标题】:disqus api for dynamic page动态页面的disqus api
【发布时间】:2011-10-02 16:48:19
【问题描述】:

我开发了一个 Web 应用程序,每个用户都可以使用提供的小部件创建自己的页面,而 disqus api 是其中一个小部件。我试图在网站上使用 disqus api http://docs.disqus.com/developers/universal/,但我有点困惑或者我可以说不能做一些事情,让我用一个场景来解释你。假设用户 A 来并在他的页面中添加了 disqus 小部件,他可以通过这个 url 访问他的页面,比如“www.domain.com/xxx”,他可以在其中使用他的 disqus 小部件,我正在使用通用 api,但我想我需要动态更新 disqus_identifier 和 disqus_url。我如何为不同的用户或多个用户动态地做到这一点。

请帮帮我

【问题讨论】:

  • 你使用什么服务器端技术?
  • @Gaby aka G. Petrioli servlet 和 JSP

标签: javascript jquery ajax jsp disqus


【解决方案1】:

Disqus 嵌入不需要disqus_identifierdisqus_url 参数。但是,根据您正在寻找的功能(从您的问题中不清楚),您可能需要它们来满足您的要求。

由于您的页面由小部件组成,我假设没有“永久链接” URL 仅链接到 Disqus 小部件。因此,我建议您根本不要设置 disqus_url 参数。 (不设置这个参数,disqus 会自己找出合适的 URL。)

您用来设置disqus_identifier 的方法将确定新的disqus 线程如何以及何时出现在小部件中。如果您希望每个用户在其小部件中看到唯一的 disqus 线程,请将 disqus_identifier 设置为该用户的 ID。在 JSP 中,这可能类似于以下内容(但实际实现完全取决于您的独特应用程序)。

// ...
%>
<div id="disqus_thread"></div>
<script type="text/javascript">
    /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
    var disqus_shortname = 'example'; // required: replace example with your forum shortname

    // The following are highly recommended additional parameters. Remove the slashes in front to use.
    var disqus_identifier = '<%=currentUser.getID()%>';
    // var disqus_url = 'http://example.com/permalink-to-page.html';

    /* * * DON'T EDIT BELOW THIS LINE * * */
    (function() {
        var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
        dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
        (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
    })();
</script>
<%

【讨论】:

    猜你喜欢
    • 2012-02-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-03
    相关资源
    最近更新 更多