动态页面的disqus api

发布于 2024-11-19 13:37:05 字数 420 浏览 1 评论 0原文

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

请帮助我

I developing a web application where each user can create the his own pages using the widgets provided and disqus api is one of the widgets. I trying to use the disqus api http://docs.disqus.com/developers/universal/ for the web site, but I am little confused or I can say not able to do few things,let me explain u with a scenario. Suppose user A comes and adds disqus widget in his page and he can access his page through this url say "www.domain.com/xxx" where he can use his disqus widget, I am using the universal api but I guess I need to dynamically update the disqus_identifier and also disqus_url. How do I do it dynamically for different users or multiple users.

Kindly help me out

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无人接听 2024-11-26 13:37:05

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

由于您的页面是由小部件组成的,因此我假设不存在仅链接到 Disqus 小部件的“永久链接”URL。因此,我建议您根本不要设置 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>
<%

The disqus_identifier and disqus_url parameters are not required for Disqus to embed. However, depending on the functionality you are looking for (which is not clear from your question) you may need them to satisfy your requirements.

Since your page is composed of widgets, I assume there is no "permalink" URL that links to just the Disqus widget. For that reason, I would recommend you do not set the disqus_url parameter at all. (By not setting this parameter, disqus will figure out the appropriate URL on its own.)

The method you use to set the disqus_identifier will determine how and when a new disqus thread appears in the widget. If you want each user to see a unique disqus thread in their widget, set disqus_identifier to that user's ID. In JSP, this might look something like the following (but the actual implementation completely depends on your unique application).

// ...
%>
<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>
<%
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文