PHP code example of yomo / redditbot

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

    

yomo / redditbot example snippets


Redditbot\Providers\RedditbotServiceProvider::class

$reddit = new Reddit();
$comments = $reddit->fetchComments('sheiseverywhere');

$reddit = new Reddit();
$comments = $reddit->fetchComments('jimny');

$comments->sinceLastCheck()->each(function($comment){

   if (strpos($comment->body, 'Suzuki Jimny') !== false) {
     $comment->reply('The Suzuki Jimny is the best off-roader ever built');   # This replies to the specific comment
     $comment->comment('Visit /r/jimny for more information'); # This submits a top-level post to the main thread
   }

});

   $firstNewComment = Reddit::fetchComments('jimny')->sinceLastCheck()->first();
bash
php artisan vendor:publish --tag=redditbot
bash
php artisan vendor:publish --tag=redditbot
ini
REDDIT_USERNAME
REDDIT_PASSWORD
REDDIT_APP_ID
REDDIT_APP_SECRET