h2s/reddit-api-client

此包已被弃用且不再维护。作者建议使用 zetaphor/reddit-api-client 包。

提供对reddit.com API的接口

此包尚未发布任何版本,可用的信息不多。


README

Build Status Latest Stable Version Latest Stable Version Minimum PHP Version

这是一个Reddit API的PHP客户端,基于Reddit的API构建,使用了Guzzle网络服务客户端框架

作为快速预览,以下是一些示例代码

<?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();

安装

此项目通过Composer打包。将以下内容添加到项目的composer.json文件的require部分

"zetaphor/reddit-api-client": "dev-master"

之后,只需运行php composer.phar update即可!如果您有任何问题或需要更多信息,我已创建了一个工作示例项目Reddit Console供参考。

开发状态

Reddit的API很大,./api/目录中的服务描述JSON不完整。

支持的URI

  • 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

以上列表涵盖了大多数常见交互,如登录、阅读和发布链接和评论,以及投票。然而,Reddit的API中还有许多其他服务可用,欢迎通过简单的pull request向服务描述JSON添加条目。

贡献

这是一个相当简单的项目,因此没有太多指南。如果您修复了错误或添加了功能,请将其合并回来。有两个硬性规则。

1. 测试您的更改

此项目是测试驱动的。请勿提交没有相应单元测试的代码更改。

$ make phpunit

2. 遵循PSR2

遵守PSR-2标准。

$ make phpcs

许可

此项目遵循MIT License