pifeifei/easy-api 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

pifeifei/easy-api

最新稳定版本:v0.1.13

Composer 安装命令:

composer require pifeifei/easy-api

包简介

easy api client.

README 文档

README

一个容易上手的 api 客户端工具

Requirement

  1. PHP >= 7.4
  2. Composer
  3. openssl 拓展(建议)
  4. 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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2021-11-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固