-
Notifications
You must be signed in to change notification settings - Fork 30
Home
chrischernoff edited this page Sep 15, 2012
·
8 revisions
The boilerplate stuff to get the library loaded is as follows:
<?php
require_once 'Reddit/Reddit.php';
use \RedditApiClient\Reddit;
To get starting using the API, you instantiate an object of \RedditApiClient\Reddit, like so:
$reddit = new Reddit;
If you want your $reddit object to be logged in, simply pass it a username and a password in the constructor:
$reddit = new Reddit('ProbablyHittingOnYou', 'password1');
From there, consult the \RedditApiClient\Reddit API reference to figure out how to get the data you want.
The client uses the following classes to model the data returned by the API. For example, there's a vote() method in the Comment class that means you can upvote a comment simply by calling $comment->vote(1). It's worth having a quick browse through to check out what's possible.