gigantier/php-sdk

用于Gigantier API的SDK

1.0.1 2018-08-09 15:02 UTC

This package is not auto-updated.

Last update: 2024-09-24 17:09:09 UTC


README

build

将您的PHP应用程序连接到Giganter API的SDK。

安装

您可以通过手动安装或将其添加到您的composer.json中来安装此包。

{
  "require": {
    "gigantier/php-sdk": "^1.0.0"
  }
}

使用方法

要开始,使用您的凭据创建一个新的Gigantier客户端实例。

注意:这需要一个Gigantier账户。

$config = new Config();
$config->clientId = '{your_client_id}';
$config->clientSecret = '{your_client_secret}';
$config->scope = '{api_scope}';

$gigantier = new Gigantier\Client($config);

查看API参考以了解更多有关身份验证和可用端点的信息。

API调用

以下是API调用的示例

$response = $gigantier->call("/Category/list");
if ($response->isError()) {
  // Error response
} else {
  // Ok response
}

身份验证

某些端点需要用户进行身份验证,一旦获得,必须调用authenticate()方法。

$response = $gigantier->authenticate("foo@test.com", "1111111");
if ($response->isError()) {
  // Error response
} else {
  // Ok response
}

已验证API调用

以下是已验证API调用的示例。请注意,必须首先执行authenticate()方法。

$response = $gigantier->authenticatedCall('/User/me');
if ($response->isError()) {
  // Error response
} else {
  // Ok response
}

数据发布

要执行数据发布,您需要将包含该数据的数组传递给call()方法。

$data = array('name' => 'John', 'surname' => 'Doe');
$response = $gigantier->authenticatedCall('/User/me', $data);
if ($response->isError()) {
  // Error response
} else {
  // Ok response
}

测试

在运行测试之前,请执行以下操作

composer install

然后您可以运行测试

vendor/bin/phpunit

以生成覆盖率报告

vendor/bin/phpunit --coverage-html ./coverage

贡献

感谢您考虑为Gigantier PHP SDK做出贡献。