Hi all,
I've followed the tutorial here:
but still fail to get any kind of activity when I press the button.
Following to the tutorial, I have:
- Registered an application at http://disqus.com/api/applications/
- Applied for a Public Key
- Set up an HTML Page as per the tutorial
- Set up my variables in the HTML Page, and then finally
- Added the 'Making the API Request' script to the HTML
- Click on button, nothing happens
Does anyone have a tutorial that starts from the very beginning to the end of this process? I have found videos where it's just bits and pieces here and I haven't found a live demo I can learn from.
Here's my code (with placeholder information(:
<!DOCTYPE html>
<html>
<head>
<title>Disqus Comment Counts Example</title>
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var disqusPublicKey = "DELETED FOR SECURITY -DISQUSPUBLICKEY";
var disqusShortname = "DELETED FOR SECURITY-MYDISQUSSHORTNAME"; // Replace with your own shortname
var urlArray = [];
$('.count-comments').each(function () {
var url = $(this).attr('data-disqus-url');
urlArray.push('link:' + url);
});
$('#get-counts-button').click(function () {
$.ajax({
type: 'GET',
url: "https://disqus.com/api/3.0/threads/set.jsonp",
data: { api_key: disqusPublicKey, forum : disqusShortname, thread : urlArray },
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";
$('div[data-disqus-url="' + result.response[i].link + '"]').html('<h4>' + count + countText + '</h4>');
}
}
});
});
</script>
</head>
<body>
<h1>Comment Counts Example</h1>
<div>
<a href=” folder/page-1.html”>
<h2>Test Post One</h2>
<div class=”count-comments” data-disqus-url=”http://www.mysite.com/folder/page-1.html”></div>
</a>
</div>
<div>
<a href=”folder/page-2”>
<h2>Test Post Two</h2>
<div class=”count-comments” data-disqus-url=”http://www.mysite.com/folder/page-2.html”></div>
</a>
</div>
<button type="button" id="get-counts-button">Get Comment Counts</button>
</body>
</html>
Thanks heaps,
Sar