sigwin / reddit-client
Reddit.com API
1.1.1
2023-08-17 16:36 UTC
Requires
- php: ^8.2
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^7.3
- guzzlehttp/psr7: ^2.0
Requires (Dev)
- phpunit/phpunit: ^9.0
- sigwin/infra: ~1.5.0
This package is auto-updated.
Last update: 2024-09-17 19:12:36 UTC
README
Reddit.com API
更多信息,请访问 https://ssl.reddit.com/dev/api.
安装与使用
要求
PHP 7.4 及更高版本。也应在 PHP 8.0 中工作。
Composer
要通过 Composer 安装绑定,请在 composer.json
中添加以下内容
{ "repositories": [ { "type": "vcs", "url": "https://github.com/sigwin/reddit-client.git" } ], "require": { "sigwin/reddit-client": "*@dev" } }
然后运行 composer install
手动安装
下载文件并包含 autoload.php
<?php require_once('/path/to/RedditClient/vendor/autoload.php');
入门
请遵循 安装过程,然后运行以下命令
<?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; }
API 端点
所有 URI 都是相对于 https://oauth.reddit.com
模型
授权
API 定义的授权方案
oauth2
- 类型:
OAuth
- 流程:
accessCode
- 授权 URL:
/authorize
- 作用域: N/A
测试
要运行测试,使用
composer install vendor/bin/phpunit
作者
关于此包
此 PHP 包由 OpenAPI Generator 项目自动生成
- API 版本:
1.1.0
- 构建包:
org.openapitools.codegen.languages.PhpClientCodegen