Skip to content

Instantly share code, notes, and snippets.

@talha08
Created December 19, 2016 21:53
Show Gist options
  • Save talha08/aa274cdf9b8300088632529bf769ca80 to your computer and use it in GitHub Desktop.
Save talha08/aa274cdf9b8300088632529bf769ca80 to your computer and use it in GitHub Desktop.
URl:: https://disqus.com/
//script
<script>
/**
* RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
* LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables
*/
/*
var disqus_config = function () {
this.page.url = PAGE_URL; // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = PAGE_IDENTIFIER; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};
*/
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = '//sust-nlp-lab.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<script type="text/javascript">
/*
Get Disqus comment counts given an array of URLs
Considerations
--------------
+ In most cases, you should use the default comment counting script
+ This example will make client-side API calls, which on a busy site, will exhaust your 1000 requests/hour limit quickly.
Consider requesting comment counts server-side and caching the results.
+ Make sure the domain you're hosting this page on has been added to your whitelisted domains in your application: http://disqus.com/api/applications/
Cases where you might use this
------------------------------
1. When you're counting comments on an element other than a <a> tag
2. If you're counting comments from another Disqus shortname on a page where you're using the default comment counting script
*/
$(document).ready(function () {
var disqusPublicKey = "658Pi7ZStcAN5fFHkKjpmx1Ac42urEjA4eNvElpEtKgHNL4xKoJs2O57zYnMOtY6";
var disqusShortname = "sustcse";
var urlArray = [];
$('.count-comments').each(function () {
var url = $(this).attr('data-disqus-url');
urlArray.push('link:' + url);
});
$('#GetCountsButton').click(function () {
$.ajax({
type: 'GET',
url: "https://disqus.com/api/3.0/threads/set.jsonp",
data: { api_key: disqusPublicKey, forum : disqusShortname, thread : urlArray }, // URL method
cache: false,
dataType: "jsonp",
success: function (result) {
for (var i in result.response) {
var countText = " comments";
var count = result.response[i].posts;
if (count == 1) countText = " comment";
$('h4[data-disqus-url="' + result.response[i].link + '"]').html(count + countText);
}
}
});
});
});
</script>
use this:: <div id="disqus_thread"></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment