ludicat/mycow-sdk

MyCow的REST API SDK

v1.0.0 2022-03-29 21:02 UTC

This package is auto-updated.

Last update: 2024-09-29 06:08:45 UTC


README

这个库允许你操作MyCow的REST API。

1- 设置

使用composer

composer req ludicat/mycow-sdk

2- 使用

在你的代码中,实例化核心类

$baseUrl = 'https://www.mycow.eu';
$myToken = 'xxxxxxxxxxxxxx'; // Your token was provide by MyCow's team.
$adapter = new MyCow\SDK\Adapter\Curl(); // Depend on your system. If none provide, CURL will be used.
$sdk = new MyCow\SDK\Core($baseUrl, $myToken, $adapter);

然后调用期望的端点并使用相关方法

$response = $sdk->getUser()->get($username);
if ($response->isError()) {
    throw new \Exception(sprintf('MyCow API ERROR %d: ', $response->getCode(), $response->getMessage()));
}

print_r($response->getBody());

贡献

创建一个.env.local文件并设置你的GITHUB_TOKEN变量

# .env.local
GITHUB_TOKEN=MyToken

构建

make build

启动容器(从现在开始,你将需要从这里开始使用)

make build

使用ssh连接到docker

make ssh

然后导出自动加载器

composer dump-autoload