weixin_33724659 2011-07-11 10:46 采纳率: 0%
浏览 52

动态页面的Disqus API

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

  • 写回答

1条回答 默认 最新

  • weixin_33725722 2011-07-29 15:54
    关注

    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>
    <%
    
    评论

报告相同问题?

悬赏问题

  • ¥20 Python安装cvxpy库出问题
  • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误
  • ¥15 python天天向上类似问题,但没有清零
  • ¥30 3天&7天&&15天&销量如何统计同一行
  • ¥30 帮我写一段可以读取LD2450数据并计算距离的Arduino代码
  • ¥15 C#调用python代码(python带有库)
  • ¥15 矩阵加法的规则是两个矩阵中对应位置的数的绝对值进行加和
  • ¥15 活动选择题。最多可以参加几个项目?
  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型
  • ¥15 vs2019中数据导出问题