afosto / api-client
Afosto API 客户端
0.5.4
2022-11-11 07:04 UTC
Requires
- doctrine/inflector: ^1.1
- league/oauth2-client: ^1.3
Requires (Dev)
- filp/whoops: ^2.1
- mustache/mustache: ^2.10
- symfony/console: ^3.0
- symfony/var-dumper: ^3.0
This package is auto-updated.
Last update: 2024-09-11 11:08:38 UTC
README
这是 Afosto API 的官方客户端。此客户端用 PHP 编写,可以使您与 API 交互的工作变得更加容易。
代码示例
使用您的 OAUTH2 客户端和密钥连接到 API,使用缓存驱动程序存储凭证并开始交互。
$storage = new SessionStorage(); App::run($storage, CLIENT_ID, CLIENT_SECRET);
例如,存储新客户数据,并立即使用新分配的 ID 进行新的销售。
$customer = Customer::model(); $customer->email = 'support@afosto.com'; $customer->name = 'Peter Bakker'; $customer->is_female = false; $customer->save();
$sale = new Sale::model(); $sale->customer_id = $customer->id;
还可以分页并遍历基于关系连接的对象。
foreach (Product::model()->paginate(50) as $page => $products) { foreach ($products as $product) { foreach ($product->collections as $collection) { echo $collection->name; } } }
安装
您应该使用 Composer 安装此客户端,使用以下命令
composer require afosto/api-client
之后,在项目的根目录中创建一个名为 config.php 的新文件,并根据 config.example.php 中指定的值进行设置。
API 参考
请访问 文档 以获取完整文档列表和使用内联文档。
测试
待办事项。
贡献者
您欢迎为此库做出贡献,任何问题可以直接向首席 API 开发者 Sjoerd 提出。此外,如果您发现您的代码与客户端互补,我们鼓励您提交 pull-requests。
许可证
根据 Apache License 2.0(“许可证”)许可;除非符合许可证规定,否则不得使用此文件。您可以在以下位置获得许可证副本:
https://apache.ac.cn/licenses/LICENSE-2.0
除非适用法律要求或书面同意,否则根据许可证分发的软件按“原样”分发,不提供任何明示或暗示的保证或条件。有关许可证的特定语言管辖权限和限制,请参阅许可证。