kobas / api-client
2.4
2021-03-23 14:15 UTC
Requires
- ext-curl: *
- ext-json: *
- kobas/oauth2-kobas: 1.0
Requires (Dev)
- mockery/mockery: 1.2.0
- phpunit/phpunit: ~5.7.27
- squizlabs/php_codesniffer: ~3.3.2
README
对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版本。在将来可能有用?