Download the PHP package yomo/redditbot without Composer
On this page you can find all versions of the php package yomo/redditbot. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download yomo/redditbot
More information about yomo/redditbot
Files in yomo/redditbot
Package redditbot
Short Description Laravel package for developing Reddit bots
License MIT
Informations about the package redditbot
RedditBot
RedditBot is a simple-to-use Laravel 5.x library that wraps the Reddit API to make reading, posting and commenting on Reddit threads really easy!
This library was partially inspired by Decronym.
Installation
Require this package with composer using the following command:
Laravel 5.5 or higher
Execute:
Laravel 5.4 or lower
If you are running Laravel 5.4 and below, you need to add the service provider to the providers array in config/app.php
Then execute:
Usage
This library assumes your bot has already been created through Reddit's App Panel, through which you would need to register a "personal use script" application.
More details on how to configure your bot can be found via Reddit's Quick Start instructions
Your .env file will require the following settings:
Retrieving comments from a subreddit and responding
Once this is configured, you can create an instance of the Reddit class with:
Comments are returned as a Collection, which you can easily iterate through using foreach or ->each. An example below shows how the bot replies to any instance of a specific phrase, using the "sinceLastCheck" function:
There is also a Facade available, with an example shown below:
About the author
Stuart Steedman is the head of development at Yonder Media, a South African digital media agency operating out of Pretoria. He specialises in PHP and Laravel development, and is a speaker at tech and development related conferences.