A PHP client for the Reddit API
Composer was still reporting GPL, license is now MIT
This is a big, BC-breaking release. Please don't upgrade to this version without doing your homework first, as any dependent code will be badly broken.
The central theme to this release is the adoption of the Guzzle HTTP client framework. The old custom HttpRequest
and HttpResponse
classes are gone, replaced with Guzzle's extremely mature cURL integration. And instead of custom-written methods for each supported API service, the service is described in JSON.
This is what using this client looks like now:
<?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();
This approach to API client development is, in my opinion at least, the current state-of-the-art in PHP. The changes brought by this release, although potentially inconvenient, should stand the project in good stead for several years to come.