Reddit.com API
For more information, please visit https://ssl.reddit.com/dev/api.
PHP 7.4 and later. Should also work with PHP 8.0.
To install the bindings via Composer, add the following to composer.json
:
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/sigwin/reddit-client.git"
}
],
"require": {
"sigwin/reddit-client": "*@dev"
}
}
Then run composer install
Download the files and include autoload.php
:
<?php
require_once('/path/to/RedditClient/vendor/autoload.php');
Please follow the installation procedure and then run the following:
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure OAuth2 access token for authorization: oauth2
$config = Sigwin\RedditClient\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$apiInstance = new Sigwin\RedditClient\Api\ThingApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$id = t3_11e9mr5; // string
$sr_name = pics; // string
try {
$result = $apiInstance->getInfo($id, $sr_name);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling ThingApi->getInfo: ', $e->getMessage(), PHP_EOL;
}
All URIs are relative to https://oauth.reddit.com
Class | Method | HTTP request | Description |
---|---|---|---|
ThingApi | getInfo | GET /api/info | Get thing info |
UserApi | getAbout | GET /user/{username}/about | Returns the identity of a user. |
UserApi | getSaved | GET /user/{username}/saved | Get user saved things |
UserApi | me | GET /api/me | Returns the identity of the current user. |
Authentication schemes defined for the API:
- Type:
OAuth
- Flow:
accessCode
- Authorization URL:
/authorize
- Scopes: N/A
To run the tests, use:
composer install
vendor/bin/phpunit
This PHP package is automatically generated by the OpenAPI Generator project:
- API version:
1.1.0
- Build package:
org.openapitools.codegen.languages.PhpClientCodegen