NAME

Mojo::Snoo - Mojo wrapper for the Reddit API

DESCRIPTION

Mojo::Snoo is a Perl wrapper for the Reddit API which relies heavily on the Mojo modules. Mojo::Collection was the initial inspiration for going the Mojo route. Skip to synopsis to see how Mojo::Snoo can be great for one-liners, quick scripts, and full-blown applications!

SYNOPSIS

use Mojo::Snoo;

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

# upvote each post in /r/Perl (casing does not matter)
$snoo->subreddit('Perl')->things->each(
    sub { $_->upvote }
);

# Don't want to login? That's fine.
# You can stick to methods which don't require login.
# Omitting auth details is nice for one-liners:

# print names of moderators from /r/Perl
Mojo::Snoo->new->subreddit('Perl')->mods->each( sub { say $_->name } );

# or do the same via Mojo::Snoo::Subreddit
Mojo::Snoo::Subreddit->new('Perl')->mods->each( sub { say $_->name } );

# print title and author of each post (or "thing") from /r/Perl
# returns 25 "hot" posts by default
Mojo::Snoo::Subreddit->new('Perl')->things->each( sub { say $_->title, ' posted by ', $_->author } );

# get only self posts
@selfies = Mojo::Snoo::Subreddit->new('Perl')->things->grep( sub { $_->is_self } );

# get the top 3 controversial posts ("things") on /r/AskReddit
@things = Mojo::Snoo::Subreddit->new('Perl')->things_contro_all(3);

# print past week's top video URLs from /r/videos
Mojo::Snoo::Subreddit->new('Perl')->things_top_week->each( sub { say $_->url } );

# print the /r/Perl subreddit description
say Mojo::Snoo->new->subreddit('Perl')->about->description;

# even fetch a subreddit's header image!
say Mojo::Snoo->new->subreddit('Perl')->about->header_img;

METHODS

multireddit

Returns a Mojo::Snoo::Multireddit object.

subreddit

Returns a Mojo::Snoo::Subreddit object.

Returns a Mojo::Snoo::Link object.

comment

Returns a Mojo::Snoo::Comment object.

user

Returns a Mojo::Snoo::User object.

WHY SNOO?

Snoo is reddit's alien mascot. Not to be confused with snu-snu.

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.

SEE ALSO ojo::Snoo

LICENSE

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