NAME

Net::Disqus - Disqus.com API access

VERSION

Version 0.01

SYNOPSIS

use Net::Disqus; my $disqus = Net::Disqus->new( api_secret => 'your_api_secret', );

my $reactions = $disqus->reactions->list(...);

OBJECT METHODS

new(%options)

Creates a new Net::Disqus object. Arguments that can be passed to the constructor:

api_secret  (REQUIRED)  Your Disqus API secret
secure      (optional)  When set, will use HTTPS instead of HTTP
ua          (optional)  An LWP::UserAgent instance. Use this if you want to set your own options on it.

API METHOD DOCUMENTATION

For a list of API methods and their arguments, please see http://disqus.com/api/docs/.

CALLING API METHODS

You can call API methods either by their full URL:

$disqus->fetch('/reactions/list', forum => 'foo')

Or you can get the same result like this:

$disqus->reactions->list(forum => 'foo');

Use whatever you're more comfortable with.

EXCEPTION HANDLING

When errors occur, Net::Disqus will die and throw a Net::Disqus::Exception object. The object contains two properties, 'code' and 'text. Use the below table to find out what the error was:

Code    Text
-------------------------------------------------------------------------------
0       Success
1       Endpoint not valid
2       Missing or invalid argument
3       Endpoint resource not valid
4       You must provide an authenticated user for this method
5       Invalid API key
6       Invalid API version
7       You cannot access this resource using %(request_method)s
8       A requested object was not found
9       You cannot access this resource using your %(access_type)s API key
10      This operation is not supported
11      Your API key is not valid on this domain
12      This application does not have enough privileges to access this resource
13      You have exceeded the rate limit for this resource
14      You have exceeded the rate limit for your account
15      There was internal server error while processing your request
16      Your request timed out
17      The authenticated user does not have access to this feature
500*    No such API endpoint
500*    <variable>

The above list was taken from http://disqus.com/api/docs/errors/. The HTTP status codes are not returned in the exception object. Exception code '500' is Net::Disqus' own, and will either contain the 'No such API endpoint' message if you are trying to access an endpoint not defined, or whatever error LWP::UserAgent encountered.

EXCEPTION HANDLING EXAMPLES

An example using Try::Tiny:

my $nd = Net::Disqus->new(api_secret => 'reallyinvalid');
my $res;

try {
    $res = $nd->reactions->list(forum => 'foo');
} catch {
    # $_ contains the Net::Disqus::Exception object
    #
    # $_->code should contain '5' and $_->text should contain 'Invalid API Key'
};

Another example:

my $nd = Net::Disqus->new(api_secret => 'myrealapikeygoeshere');
my $res;

try {
    $res = $nd->fetch('/this/isnt/good');
} catch {
    # $_ contains the Net::Disqus::Exception object
    #
    # $_->code should contain '500' and $_->text should contain 'No such API endpoint'
};

AUTHOR

Ben van Staveren, <madcat at cpan.org>

BUGS AND/OR CONTRIBUTING

Please report any bugs or feature requests through the web interface at https://bitbucket.org/xirinet/net-disqus/issues. If you want to contribute code or patches, feel free to fork the Mercurial repository located at https://bitbucket.org/xirinet/net-disqus and make pull requests for any patches you have.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Net::Disqus

You can also look for information at:

ACKNOWLEDGEMENTS

Parts of the code based on Disqus' official Python lib.

LICENSE AND COPYRIGHT

Copyright 2011 Ben van Staveren.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.