zetaphor / reddit-api-client
Provides an interface to the API at reddit.com
Installs: 2 506
Dependents: 0
Suggesters: 0
Security: 0
Stars: 73
Watchers: 10
Forks: 30
Open Issues: 1
Requires
- php: >=5.3.0
- guzzle/guzzle: 3.9.2
Requires (Dev)
- mockery/mockery: dev-master
- phpunit/phpunit: 3.7.*@dev
- squizlabs/php_codesniffer: 1.*
This package is not auto-updated.
Last update: 2024-11-09 19:04:42 UTC
README
This is a PHP client for Reddit's API, built on the Guzzle web service client framework.
As a quick taster, here's some sample code:
<?php require 'vendor/autoload.php'; $clientFactory = new Reddit\Api\Client\Factory; $client = $clientFactory->createClient(); $login = $client->getCommand( 'Login', array( 'api_type' => 'json', 'user' => 'Example_User', 'passwd' => 'password123', ) ); $login->execute(); $submit = $client->getCommand( 'Submit', array( 'sr' => 'programming', 'kind' => 'link', 'title' => 'Mongo DB Is Web Scale', 'url' => 'http://www.youtube.com/watch?v=b2F-DItXtZs', ) ); $submit->execute();
Installation
This project is packaged with Composer. Add the
following the the require
section of your project's composer.json
:
"zetaphor/reddit-api-client": "dev-master"
After that just run php composer.phar update
and you're good to go! If you
have any trouble, or want more detail, I've set up a working example "Reddit
Console" project for reference purposes.
Development Status
Reddit's API is big, and the service description JSON in the
./api/
directory
is incomplete.
Supported URIs
api/login/{user}
api/me.json
api/register
api/submit
api/del
api/vote
api/comment
api/message
by_id/t3_{id}.json
r/{subreddit}.json
user/{id}.json
user/{id}/about.json
The above list covers many of the most common interactions such as logging in, reading and posting links and comments, and casting votes. However, there are dozens more services available in Reddit's API, and simple pull requests adding entries to the service description JSON are very welcome.
Contributing
This is a fairly simple project so there aren't many guidelines. If you've fixed a bug or added a feature, let's get it merged back in. There are two hard rules.
1. Test-drive your changes
This project is test-driven. Please don't submit any code changes without a corresponding set of unit tests.
$ make phpunit
2. Follow PSR2
Stick to the PSR-2 standard.
$ make phpcs
License
This project is released under the MIT License.