pifeifei/easy-api
最新稳定版本:v0.1.13
Composer 安装命令:
composer require pifeifei/easy-api
包简介
easy api client.
README 文档
README
一个容易上手的 api 客户端工具
Requirement
- PHP >= 7.4
- Composer
- openssl 拓展(建议)
- fileinfo 拓展(建议)
Installation
composer require "pifeifei/easy-api"
Usage
$config = [ 'config' => [ 'app_key' => 'app key string', 'app_secret' => 'app secret string' ], 'request' => [ "uri" => 'https://httpbin.org/anything', "sandbox_uri" => 'https://httpbin.org/anything/sandbox', "method" => Pff\EasyApi\API::METHOD_JSON, // 默认请求方式,可选:GET, POST, JSON "sign" => [ "position" => Pff\EasyApi\API::SIGN_POSITION_HEAD, "key" => "sign", "appends" => [ "sign_type" => 'MD5' ], ], "signature" => Pff\EasyApi\Signature\MD5Signature::class, // 继承 \Pff\EasyApi\Signature\SignatureInterface::class "formatter" => Pff\EasyApi\Format\HttpBinFormatter::class, "cache" => Pff\EasyApi\Cache\Cache::class, // auth 获取 access_token 等数据后,保存数据时会用到 "format" => Pff\EasyApi\API::RESPONSE_FORMAT_JSON, // 响应信息格式化 ] ]; $client = new Client($config); $response = $client->request(); // get $response = $client->method(Pff\EasyApi\API::METHOD_GET) ->path("any/path/to") ->setData(['a'=>'foo', 'b'=>'bar']) ->request(); // json post $response = $client->path("any/path/to") ->setData(['a'=>'foo', 'b'=>'bar']) ->request();
把上面代码封装一下会更好用,可以参考 tests/Feature/Clients/WechatClient
test
phpunit # phpunit --list-groups # 微信开放平台测试 #php -S 0.0.0.0:8080 -t ./tests/stubs/wechat #phpunit --group wechat
统计信息
- 总下载量: 63
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2021-11-14