mega6382 / rest-api-wrapper
RESTful API 的 Curl 包装器
dev-master
2017-12-04 07:41 UTC
This package is auto-updated.
Last update: 2024-09-25 06:47:08 UTC
README
RESTful API 的 Curl 包装器
使用 composer 进行安装
composer require mega6382/rest-api-wrapper
快速示例
创建 restApiWrapper 实例
$url = "https://example.com/"; $raw = new raw\restApiWrapper($url);
发送带有参数、自定义头和返回 JSON 对象的 POST 请求
$request = $raw->post( 'ufkbi1uf', // Endpoint to the API [ //POST Params 'param1' => 'abc', 'param2' => 'def', 'param3' => 'ghi', ], [ //Request Headers 'Content-Type: application/xml', 'Connection: Keep-Alive' ], 'json' //Return type ); var_dump($request);
发送没有参数或自定义头并返回字符串的 GET 请求
$request = $raw->get('ufkbi1uf', [], [], ''); var_dump($request);
发送带有参数但没有自定义头并返回字符串的 OPTIONS 请求
$request = $raw->options('ufkbi1uf', ['name' => 'basil'], [], ''); var_dump($request);