The Reddit SDK is a wrapper around the Reddit APIs: https://github.com/reddit/reddit/wiki/API
Before making requests to any of the methods of the Reddit SDK, you first need to authenticate by calling the login method with your username and password. This will populate your user hash and session data.
require_once("reddit.php"); $reddit = new reddit("USERNAME", "PASSWORD");
Once you are authenticated, you may then make requests to any of the methods in the SDK.
Creating a New Story
$title = "British coffee-powered car breaks world record"; $link = "http://www.extremetech.com/extreme/97287-british-coffee-powered-car-breaks-world-record"; $subreddit = "technology" $response = $reddit->createStory($title, $link, $subreddit);
Get User Information
$userData = $reddit->getUser();
Get User Subscriptions
$subscriptions = $reddit->getSubscriptions();
Get Page Information
$pageInfo = $reddit->getPageInfo("http://i.imgur.com/QxdCd.jpg");
Save Story
$response = $reddit->savePost("t3_n6ocq"));
Unsave Story
$response = $reddit->unsavePost("t3_n6ocq");
Hide Post
$response = $reddit->hidePost("t3_n6ocq"));
Unhide Post
$response = $reddit->unhidePost("t3_n6ocq");
Get Posts
$response = $reddit->getListing("technology", 5);
Get Saved User Posts
$response = $reddit->getSaved("USERNAME");
Get Raw JSON
$response = $reddit->getRawJSON("/r/funny/comments/12ma0a/this_guy_showed_up_at_our_party_last_night_didnt/");
//get the JSON for the top technology post $response1 = $reddit->getListing("technology", 1); $response2 = $reddit->getRawJSON($response1->data->children[0)]->data->permalink);
Share Post
$response = $reddit->sharePost("t3_jp2k7", "Jon", "me@mysite.com", "you@yoursite.com", "Check out this post");
Add Comment
$response = $reddit->addComment("t3_jp2k7", "Hey!\n\n**[search!](http://www.google.com/)**");
Add Vote
$response = $reddit->addVote("t3_n6ocq", 1);
Set or Clear a User’s Flair in a Subreddit
$response = $reddit->setFlair("motorcycles", "jcleblanc", "ZZR600", "kawasaki");
Download the Flair Assignments of a Subreddit
$response = $reddit->getFlairList("motorcycles", 100, "t2_39qab", "t2_39qab");
Post a CSV File of Flair Settings to a Subreddit
$response = $reddit->setFlairCSV("motorcycles", "jcleblanc,ZZR600,kawasaki\n...");