kobas/api-client

2.4 2021-03-23 14:15 UTC

This package is auto-updated.

Last update: 2024-09-18 16:14:36 UTC


README

Latest Version Software License Build Status Documentation Coverage Status Quality Score Total Downloads

对API请求进行签名并允许通过cURL方法进行交互。

示例

/**
 * Setup
 */
$companyId = 0000;// company id provided by Kobas
$clientId = '';// client id provided by Kobas
$clientSecret = '';// client secret provided by Kobas
$clientScope = ''; // client scope provided by Kobas

$provider = new \Kobas\APIClient\Auth\Provider($companyId, $clientId, $clientSecret, $clientScope);
$client = new \Kobas\APIClient\Client($provider);

/**
 * Usage
 */
$response = $client->get('customer/search', ['email' => 'example@example.com']);
echo json_encode($response, JSON_PRETTY_PRINT);

客户端函数

get($route, $params = array(), $headers = array())

向提供的路由发送HTTP GET请求。

post($route, $params = array(), $headers = array())

向提供的路由发送HTTP POST请求。

put($route, $params = array(), $headers = array())

向提供的路由发送HTTP PUT请求。

delete($route, $params = array(), $headers = array())

向提供的路由发送HTTP DELETE请求。

getRequestInfo()

以数组的形式返回最后执行的请求的curl_getinfo()的结果。

setAPIBaseURL($url)

允许覆盖基本URL(通常只在开发中需要)。

setAPIVersion($version)

允许覆盖API版本。在将来可能有用?