NAME

Mojo::Snoo::User - Mojo wrapper for Reddit Users

SYNOPSIS

use Mojo::Snoo::User;

# OAuth ONLY. Reddit is deprecating cookie auth soon.
my $user = Mojo::Snoo::User->new(
    username      => 'foobar',
    password      => 'very_secret',
    client_id     => 'oauth_client_id',
    client_secret => 'very_secret_oauth',
);

# send message to /u/foobar
$user->send_message(
    title => 'this is not spam',
    body  => q@Hi, how ya doin'?@,
);

# or do non-OAuth things with a user object
my $user = Mojo::Snoo::User->new('username');

ATTRIBUTES

name

The name of the user. This is required for object instantiation. The constructor can accept a single string value or key/value pairs. Examples:

Mojo::Snoo::User->new('reddit_buddy')->name;
Mojo::Snoo::User->new(name => 'reddit_buddy')->name;

METHODS

send_message

Send private message to user.

POST /api/compose.

OAuth is required for this method.

# OAuth is required for this endpoint
my $user = Mojo::Snoo::User->new(%oauth, name => 'some_user');

$user->send_message(
    title => 'title goes here',
    body  => 'body goes here',
);

Be aware! This endpoint may require you to complete a CAPTCHA if your account lacks sufficient karma. If this happens, Mojo::Snoo::User will provide you with a CAPTCHA image link and wait for the answer via STDIN before proceding.

STDIN is really only useful for personal bots and scripts. When Mojo::Snoo supports more forms of authentication, it would be nice to let the user change this via the class constructor.

subreddit

Returns a Mojo::Snoo::Subreddit object.

thing

Returns a Mojo::Snoo::Link object.

comment

Returns a Mojo::Snoo::Comment object.

user

Returns a Mojo::Snoo::User object.

API DOCUMENTATION

Please see the official Reddit API documentation for more details regarding the usage of endpoints. For a better idea of how OAuth works, see the Quick Start and the full documentation. There is also a lot of useful information of the redditdev subreddit.

LICENSE

The (two-clause) FreeBSD License. See LICENSE for details.