pnoeric / discourse-api-php
Discourse API for PHP 的库
2.0.0
2020-04-29 12:28 UTC
Requires
- ext-curl: *
- ext-json: *
Requires (Dev)
- phpunit/phpunit: ^7
- vlucas/phpdotenv: ^4.1
This package is auto-updated.
Last update: 2024-09-23 21:37:58 UTC
README
这是访问 Discourse API 的 PHP 库的 Composer 包版本。
关于 Discourse 的更多信息:https://www.discourse.org/
Discourse API 文档:https://docs.discourse.org/
特性
- 支持基于头的认证(自 2020 年 4 月起 Discourse 所需)
- 包含针对开发者的测试套件
变更日志
- 2.1 - 修复了一个小而讨厌的 bug
历史
最初由 DiscourseHosting 发布于 https://github.com/discoursehosting/discourse-api-php.
贡献者包括:
- https://github.com/richp10
- https://github.com/timolaine
- https://github.com/vinkashq
- https://github.com/kazad/discourse-api-php
- https://github.com/timolaine/discourse-api-php
Eric Mueller 在 2020 年 3 月/4 月添加了许多方法并进行了一次重大重构,现在位于 https://github.com/pnoeric/discourse-api-php.
如何使用
只需使用 Composer 包含它: composer require pnoeric/discourse-api-php
然后
// set up key in Discourse first - recommend system key for all users $key = 'my-secret-discourse-api-key'; $hostname = 'forums.example.com'; $api = new \pnoeric\DiscourseAPI($hostname, $key); // and you're off and running! // look through the src/DiscourseAPI.php file for methods // for example: $results = $api->getTopTopics(); // if you aren't sure what the API returns from a call, just look at it: $results = $api->getUserByDiscourseId( 1 ); var_dump($results); // you can also get a lot of info from the tests (see tests/DiscourseApiTest.php).
针对开发者
我非常希望看到您对这个库的更改和改进!请随时提交拉取请求,如果您添加/重构了方法,请包括一个新的测试。
测试
设置
- 运行
composer install
以安装 PHPUnit 和其他辅助库 - 将测试文件夹中的
.env.example
文件复制,将其重命名为.env
并填写空白
运行测试
在终端中,从项目的根目录开始,输入: ./vendor/bin/phpunit tests/DiscourseApiTest.php