<commit_before>h1. Reddit PHP SDK

The Reddit SDK is a wrapper around the Reddit APIs: https://github.com/reddit/reddit/wiki/API

h2. Initiating Your Login Session

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.
<notextile>
<pre>
require_once("reddit.php");
$reddit = new reddit("USERNAME", "PASSWORD");
</pre>
</notextile>

h2. SDK Methods

Once you are authenticated, you may then make requests to any of the methods in the SDK.  

*Creating a New Story*
<notextile>
<pre>
$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);
</pre>
</notextile>

*Get User Information*
<notextile>
<pre>
$userData = $reddit->getUser();
</pre>
</notextile>

*Get User Subscriptions*
<notextile>
<pre>
$subscriptions = $reddit->getSubscriptions();
</pre>
</notextile>

*Get Page Information*
<notextile>
<pre>
$pageInfo = $reddit->getPageInfo("http://i.imgur.com/QxdCd.jpg");
</pre>
</notextile>

*Save Story*
<notextile>
<pre>
$response = $reddit->savePost("t3_n6ocq"));
</pre>
</notextile>

*Unsave Story*
<notextile>
<pre>
$response = $reddit->unsavePost("t3_n6ocq");
</pre>
</notextile>

*Hide Post*
<notextile>
<pre>
$response = $reddit->hidePost("t3_n6ocq"));
</pre>
</notextile>

*Unhide Post*
<notextile>
<pre>
$response = $reddit->unhidePost("t3_n6ocq");
</pre>
</notextile>

*Get Posts*
<notextile>
<pre>
$response = $reddit->getListing("technology", 5);
</pre>
</notextile>

*Share Post*
<notextile>
<pre>
$response = $reddit->sharePost("t3_jp2k7", "Jon", "<EMAIL>", "<EMAIL>", "Check out this post");
</pre>
</notextile>

*Add Comment*
<notextile>
<pre>
$response = $reddit->addComment("t3_jp2k7", "Hey!\n\n**[search!](http://www.google.com/)**");
</pre>
</notextile>

*Add Vote*
<notextile>
<pre>
$response = $reddit->addVote("t3_n6ocq", 1);
</pre>
</notextile>

*Set or Clear a User's Flair in a Subreddit*
<notextile>
<pre>
$response = $reddit->setFlair("motorcycles", "jcleblanc", "ZZR600", "kawasaki");
</pre>
</notextile>

*Download the Flair Assignments of a Subreddit*<commit_msg>Added documentation for getRawJSON<commit_after>h1. Reddit PHP SDK

The Reddit SDK is a wrapper around the Reddit APIs: https://github.com/reddit/reddit/wiki/API

h2. Initiating Your Login Session

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.
<notextile>
<pre>
require_once("reddit.php");
$reddit = new reddit("USERNAME", "PASSWORD");
</pre>
</notextile>

h2. SDK Methods

Once you are authenticated, you may then make requests to any of the methods in the SDK.  

*Creating a New Story*
<notextile>
<pre>
$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);
</pre>
</notextile>

*Get User Information*
<notextile>
<pre>
$userData = $reddit->getUser();
</pre>
</notextile>

*Get User Subscriptions*
<notextile>
<pre>
$subscriptions = $reddit->getSubscriptions();
</pre>
</notextile>

*Get Page Information*
<notextile>
<pre>
$pageInfo = $reddit->getPageInfo("http://i.imgur.com/QxdCd.jpg");
</pre>
</notextile>

*Save Story*
<notextile>
<pre>
$response = $reddit->savePost("t3_n6ocq"));
</pre>
</notextile>

*Unsave Story*
<notextile>
<pre>
$response = $reddit->unsavePost("t3_n6ocq");
</pre>
</notextile>

*Hide Post*
<notextile>
<pre>
$response = $reddit->hidePost("t3_n6ocq"));
</pre>
</notextile>

*Unhide Post*
<notextile>
<pre>
$response = $reddit->unhidePost("t3_n6ocq");
</pre>
</notextile>

*Get Posts*
<notextile>
<pre>
$response = $reddit->getListing("technology", 5);
</pre>
</notextile>

*Get Raw JSON*
<notextile>
<pre>
$response = $reddit->getRawJSON("/r/funny/comments/12ma0a/this_guy_showed_up_at_our_party_last_night_didnt/");
</pre>
<pre>
//get the JSON for the top technology post
$response1 = $reddit->getListing("technology", 1);
$response2 = $reddit->getRawJSON($response1->data->children[0)]->data->permalink);
</pre>
</notextile>

*Share Post*
<notextile>
<pre>
$response = $reddit->sharePost("t3_jp2k7", "Jon", "<EMAIL>", "<EMAIL>", "Check out this post");
</pre>
</notextile>

*Add Comment*
<notextile>
<pre>
$response = $reddit->addComment("t3_jp2k7", "Hey!\n\n**[search!](http://www.google.com/)**");
</pre>
</notextile>

*Add Vote*
<notextile>
<pre>
$response = $reddit->addVote("t3_n6ocq", 1);
</pre>
</notextile>

*Set or Clear a User's Flair in a Subreddit*
<notextile>
<pre>
$response = $reddit->setFlair("motorcycles", "jcleblanc", "ZZR600", "kawasaki");
</pre>
</notextile>

*Download the Flair Assignments of a Subreddit*
{'fraction_non_alphanumeric': 0.17933491686460806, 'fraction_numerical': 0.013064133016627079, 'mean_word_length': 5.66622691292876, 'pattern_counts': {'":': 0, '<': 125, '<?xml version=': 0, '>': 158, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3546465', 'n_tokens_mistral': 1975, 'n_tokens_neox': 1947, 'n_words': 494}