PHP code example of coliving / laravel-reddit-api

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

    

coliving / 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' => '',
    'password' => '',
    'app_id' => '',
    '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"