Disqus for C5 calling on php instead of Javascript
Permalink
Hi all,
I'm sure many of you have had a look at the Disqus comments system and thought about using it for your blog. It's a great way of encouraging interaction on your blog.
Katz has done a great job of getting Disqus working on your Concrete5 blog:http://www.concrete5.org/community/forums/customizing_c5/adding-sma...
However, the problems are that:
1. All comments are loaded via Javascript - not php
- This is the main issue
2. Comments are all hosted on Disqus
- I.e. You're reliant on Disqus for hosting those valuable conversations - Incredibly important for any blogger
Now Wordpress has released a Disqus plugin which spits out comments from it's own database and works with php - it's a much better solution.http://wordpress.org/extend/plugins/disqus-comment-system/...
Wordpress's solution is relatively advanced and it would be useful to work towards similar functionality..
QUESTION:
1. Does anyone know how you can pull in "Comments", "Comment Counts" etc via php instead of Javascript.
- Placing results in <noscript> tags is an option.
If this is possible we could start dumping comments into the Concrete5 database for backup.
Cheers
I'm sure many of you have had a look at the Disqus comments system and thought about using it for your blog. It's a great way of encouraging interaction on your blog.
Katz has done a great job of getting Disqus working on your Concrete5 blog:http://www.concrete5.org/community/forums/customizing_c5/adding-sma...
However, the problems are that:
1. All comments are loaded via Javascript - not php
- This is the main issue
2. Comments are all hosted on Disqus
- I.e. You're reliant on Disqus for hosting those valuable conversations - Incredibly important for any blogger
Now Wordpress has released a Disqus plugin which spits out comments from it's own database and works with php - it's a much better solution.http://wordpress.org/extend/plugins/disqus-comment-system/...
Wordpress's solution is relatively advanced and it would be useful to work towards similar functionality..
QUESTION:
1. Does anyone know how you can pull in "Comments", "Comment Counts" etc via php instead of Javascript.
- Placing results in <noscript> tags is an option.
If this is possible we could start dumping comments into the Concrete5 database for backup.
Cheers
had a look at that one and basicly does the same thing. When Javascript is turned off, all that comes out is:
Please enable JavaScript to view the comments powered by Disqus...
still need to access it via php
Please enable JavaScript to view the comments powered by Disqus...
still need to access it via php
oops, somehow missed this one. seems that disqus actually do have an api for php - downloadable here:https://github.com/disqus/disqus-php...
with documentation here:http://disqus.com/api/docs/
looks like all that's needed to be done is get the correct data using the disqus libraries. - guess I'll have a play around with these over the next few days.
If anyone's tried this before give me a heads up.
Cheers
with documentation here:http://disqus.com/api/docs/
looks like all that's needed to be done is get the correct data using the disqus libraries. - guess I'll have a play around with these over the next few days.
If anyone's tried this before give me a heads up.
Cheers
Turns out getting your comments from disqus is actually quite simple. All you need to do is sign up for an API accounthttp://disqus.com/api/applications/...
Then you just make requests for JSON files to disqus using it's API. Ignore that link to files on github I put earlier.
You can make a request to their server like so - their response is a JSON file so hold it as a variable:
From here you can echo out whatever comment details you need.
The only irritating thing is that there seems to be no 'dated' way to tell when a comment was last modified - content changed, voted as spam etc.
It's possible but....
Without hooking into the Javascript which is subject to change (downloaded from disqus) - the only way seems to be to run through the entire list of comments. Making modifications to your database every time the page is loaded.
Sounds a bit inefficient?
Then you just make requests for JSON files to disqus using it's API. Ignore that link to files on github I put earlier.
You can make a request to their server like so - their response is a JSON file so hold it as a variable:
$pageURL = currentPageURL(); // function to get your current page url $secret_key = 'yoursecretkey'; // fromhttp://disqus.com/api/applications/... $forum = 'yourforum'; $curl_start = curl_init(); curl_setopt($curl_start, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl_start,CURLOPT_URL,"http://disqus.com/api/3.0/threads/listPosts.json?api_secret=$secret_key&thread=link:$pageURL&forum=$forum&include=spam&include=approved"); // outputs both spam and approved comments $curl_data = curl_exec($curl_start); $json_array = json_decode($curl_data,true);
From here you can echo out whatever comment details you need.
The only irritating thing is that there seems to be no 'dated' way to tell when a comment was last modified - content changed, voted as spam etc.
It's possible but....
Without hooking into the Javascript which is subject to change (downloaded from disqus) - the only way seems to be to run through the entire list of comments. Making modifications to your database every time the page is loaded.
Sounds a bit inefficient?
Also note that you can <strong>manually</strong> download an xml file with all your Disqus posts:
Admin > Tools > Import/ Export
It's a good way to keep an accurate backup and you can update your DB this way if Disqus disappears.
Admin > Tools > Import/ Export
It's a good way to keep an accurate backup and you can update your DB this way if Disqus disappears.
http://www.concrete5.org/marketplace/addons/disqus-comments/...