PHP code example of tatter / reddit

1. Go to this page and download the library: Download tatter/reddit library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tatter / reddit example snippets


foreach (service('reddit')->fetch('new') as $thing)
{
	echo (string) $thing; // "Comment" or "Link"
	echo $thing->link_permalink; // E.g. "https://www.reddit.com/r/pythonforengineers/comments/jox9zy/great_video_for_the_python_programers"
}


try
{
	$comments = $reddit->subreddit('php')->fetch('new');
}
catch (\Tatter\Reddit\Exceptions\RedditException $e)
{
	echo $e->getMessage(); // "API responded with an error: Invalid authorization"
}