mezon / custom-client
小型自定义客户端例程
1.0.15
2022-01-10 15:32 UTC
Requires
- php: >=7.2.0
Requires (Dev)
- phpunit/php-token-stream: 3.1.2
- phpunit/phpunit: ^8.5
- vimeo/psalm: ^4.2
README
安装
仅打印
composer require mezon/custom-client
使用理由
- 它可以帮助您快速创建REST API客户端!只需看看这个创建Jira API客户端的示例
- 100%代码覆盖率
- 在Scrutinizer上获得10.0分
发送请求
您可以发送不同类型的请求。
$client = new \Mezon\CustomClient\CustomClient(); // sending get request $client->sendGetRequest('https://your-api/end/point/?param=1'); // sending post request $client->sendPostRequest('https://your-api/end/point/', ['param' => 1]); // sending put request $client->sendPutRequest('https://your-api/end/point/', ['param' => 1]); // sending delete request $client->sendDeleteRequest('https://your-api/end/point/', ['param' => 1]);
幂等键
为了确保您的数据修改请求只执行一次 - 使用幂等键。
它们在头部传递,可以设置如下
$client->setIdempotencyKey('some hash, like md5 or GUID or something like that');
之后,在您所有的请求中都会添加头部Idempotency-Key。
注意,此键不会自动删除。您应该手动删除它
$client->setIdempotencyKey(''); // this call drops the key
了解更多信息
更多信息请参阅这里