Reputation: 4649
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
Upvotes: 4
Views: 2464
Reputation: 34685
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>
<%
Upvotes: 5