You are here

README.txt in Disqus 7

Same filename and directory in other branches
  1. 6 README.txt
README for Disqus for Drupal 7

Disqus 7.x-1.x
=================================

Disqus Official PHP API Support
=================================

INSTALL
=============
You will need to install the Libraries API module (7.x-2.x branch).

https://drupal.org/project/libraries

The Disqus Official PHP API can be downloaded at:

https://github.com/disqus/disqus-php

Copy the contents of the disqusapi folder to sites/all/libraries/disqusapi.
You will need to obtain your user access key from the application specific
page found here:

http://disqus.com/api/applications/

BUILT-IN FEATURES
=============
This module can automatically update and/or delete your Disqus threads when you
delete/update your nodes.

Tracking new comments and replies via "Google Analytics" analytic service.

Visit Disqus configuration page after you installed Disqus API to configure it's
behaviour. 

EXAMPLES
=============
You can find the API reference here:

http://disqus.com/api/docs/

Any of these methods can be called by creating an instance of the Disqus API
through disqus_api(). You must use try/catch to avoid php throwing a general
exception and stopping script execution.

For a full explanation of the official API you can view the readme located here:

https://github.com/disqus/disqus-php/blob/master/README.rst

Example: Calling threads/details and threads/update

  $disqus = disqus_api();
  if ($disqus) {
    try {
      // Load the thread data from disqus. Passing thread is required to allow the thread:ident call to work correctly. There is a pull request to fix this issue.
      $thread = $disqus->threads->details(array('forum' => $node->disqus['domain'], 'thread:ident' => $node->disqus['identifier'], 'thread' => '1', 'version' => '3.0'));
    }
    catch (Exception $exception) {
      drupal_set_message(t('There was an error loading the thread details from Disqus.'), 'error');
      watchdog('disqus', 'Error loading thread details for node @nid. Check your API keys.', array('@nid' => $node->nid), WATCHDOG_ERROR, 'admin/config/services/disqus');
    }
    if (isset($thread->id)) {
      try {
        $disqus->threads->update(array('access_token' => variable_get('disqus_useraccesstoken', ''), 'thread' => $thread->id, 'forum' => $node->disqus['domain'], 'title' => $node->disqus['title'], 'url' => $node->disqus['url'], 'version' => '3.0'));
      }
      catch (Exception $exception) {
        drupal_set_message(t('There was an error updating the thread details on Disqus.'), 'error');
        watchdog('disqus', 'Error updating thread details for node @nid. Check your user access token.', array('@nid' => $node->nid), WATCHDOG_ERROR, 'admin/config/services/disqus');
      }
    }
  }

File

README.txt
View source
  1. README for Disqus for Drupal 7
  2. Disqus 7.x-1.x
  3. =================================
  4. Disqus Official PHP API Support
  5. =================================
  6. INSTALL
  7. =============
  8. You will need to install the Libraries API module (7.x-2.x branch).
  9. https://drupal.org/project/libraries
  10. The Disqus Official PHP API can be downloaded at:
  11. https://github.com/disqus/disqus-php
  12. Copy the contents of the disqusapi folder to sites/all/libraries/disqusapi.
  13. You will need to obtain your user access key from the application specific
  14. page found here:
  15. http://disqus.com/api/applications/
  16. BUILT-IN FEATURES
  17. =============
  18. This module can automatically update and/or delete your Disqus threads when you
  19. delete/update your nodes.
  20. Tracking new comments and replies via "Google Analytics" analytic service.
  21. Visit Disqus configuration page after you installed Disqus API to configure it's
  22. behaviour.
  23. EXAMPLES
  24. =============
  25. You can find the API reference here:
  26. http://disqus.com/api/docs/
  27. Any of these methods can be called by creating an instance of the Disqus API
  28. through disqus_api(). You must use try/catch to avoid php throwing a general
  29. exception and stopping script execution.
  30. For a full explanation of the official API you can view the readme located here:
  31. https://github.com/disqus/disqus-php/blob/master/README.rst
  32. Example: Calling threads/details and threads/update
  33. $disqus = disqus_api();
  34. if ($disqus) {
  35. try {
  36. // Load the thread data from disqus. Passing thread is required to allow the thread:ident call to work correctly. There is a pull request to fix this issue.
  37. $thread = $disqus->threads->details(array('forum' => $node->disqus['domain'], 'thread:ident' => $node->disqus['identifier'], 'thread' => '1', 'version' => '3.0'));
  38. }
  39. catch (Exception $exception) {
  40. drupal_set_message(t('There was an error loading the thread details from Disqus.'), 'error');
  41. watchdog('disqus', 'Error loading thread details for node @nid. Check your API keys.', array('@nid' => $node->nid), WATCHDOG_ERROR, 'admin/config/services/disqus');
  42. }
  43. if (isset($thread->id)) {
  44. try {
  45. $disqus->threads->update(array('access_token' => variable_get('disqus_useraccesstoken', ''), 'thread' => $thread->id, 'forum' => $node->disqus['domain'], 'title' => $node->disqus['title'], 'url' => $node->disqus['url'], 'version' => '3.0'));
  46. }
  47. catch (Exception $exception) {
  48. drupal_set_message(t('There was an error updating the thread details on Disqus.'), 'error');
  49. watchdog('disqus', 'Error updating thread details for node @nid. Check your user access token.', array('@nid' => $node->nid), WATCHDOG_ERROR, 'admin/config/services/disqus');
  50. }
  51. }
  52. }