PHP code example of raicem / reddit-public-api-wrapper
1. Go to this page and download the library: Download raicem/reddit-public-api-wrapper 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/ */
raicem / reddit-public-api-wrapper example snippets
use RedditWrapper\Wrapper;
use RedditWrapper\WrapperClient;
$wrapper = new Wrapper(new WrapperClient());
use RedditWrapper\Queries\SubredditQuery;
use RedditWrapper\Enums\SubredditSort;
use RedditWrapper\Enums\SubredditSortTime;
$query = new SubredditQuery([
'subreddit' => 'formula1',
]);
$response = $wrapper->fetch($query);
use RedditWrapper\Queries\SubredditQuery;
use RedditWrapper\Enums\SubredditSort;
use RedditWrapper\Enums\SubredditSortTime;
$query = new SubredditQuery([
'subreddit' => 'formula1',
'sort' => SubredditSort::TOP,
'sortTime' => SubredditSortTime::WEEK,
]);
$response = $wrapper->fetch($query);
use RedditWrapper\Queries\UserQuery;
$query = new UserQuery([
'username' => 'unidan',
]);
$response = $wrapper->fetch($query);
use RedditWrapper\Wrapper;
use RedditWrapper\WrapperClient;
$wrapper = new Wrapper(new WrapperClient());
$response = $wrapper->formula1();