PHP code example of codewizz / laravel-reddit-api

1. Go to this page and download the library: Download codewizz/laravel-reddit-api 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/ */

    

codewizz / laravel-reddit-api example snippets


use RedditAPI;

//fetch top Reddit posts
RedditAPI::getTop();

//fetch top picture posts of Margot Robbie, limit to 100
RedditAPI::search('Margot Robbie ', null, 'top', null, 'pics', 100);

// config/app.php
'providers' => [
    ...
    CodeWizz\RedditAPI\RedditAPIServiceProvider::class,
    ...
];

// config/app.php
'aliases' => [
    ...
    'RedditAPI' => CodeWizz\RedditAPI\RedditAPIFacade::class,
    ...
];

return [
    'endpoint_standard' => 'https://www.reddit.com',
    'endpoint_oauth' => 'https://oauth.reddit.com',
    
    'username' => env('REDDIT_USERNAME', ''),
    'password' => env('REDDIT_PASSWORD', ''),
    'app_id' => env('REDDIT_APP_ID', ''),
    'app_secret' => env('REDDIT_APP_SECRET', ''),
    
    'response_format' => 'STD', // STD | ARRAY
    
    'scopes' => 'save,modposts,identity,edit,flair,history,modconfig,modflair,modlog,modposts,modwiki,mysubreddits,privatemessages,read,report,submit,subscribe,vote,wikiedit,wikiread'
];
 bash
php artisan vendor:publish --provider="CodeWizz\RedditAPI\RedditAPIServiceProvider"