oywenjiao/php-tool-kit

This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

集成常用工具类

1.3.0 2021-05-25 02:09 UTC

This package is auto-updated.

Last update: 2021-08-25 02:50:54 UTC


README

PHP工具箱

安装

composer require oywenjiao/php-tool-kit

文件目录说明

  • Express 快递工具箱

    • Baidu 百度快递查询接口

      • 使用示例

          $obj = new Baidu();
          $response = $obj->query('YT123456', '圆通速递');
    • BirdLogistics 快递鸟查询接口

      • 使用示例

          $appKey = 'your app_key';   // 快递鸟账号密钥
          $businessId = 'your businessId';    // 快递鸟账号id
          $obj = new BirdLogistics($appKey, $businessId);
          $trade_sn = '123456';   // 商户订单号
          $ship_code  = 'YTO';    // 快递公司编码
          $ship_sn    = '123456'; // 快递单号
          $response = $obj->getOrderTracesByJson($trade_sn, $ship_code, $ship_sn);
  • Wechat 微信生态

    • WxBase 微信操作公共类,所有的微信相关api基于该公共类的基础上进行调用

      • 示例

          $appId = 'your appid';  // 公众号appid
          $appSecret = 'your appSecret';  // 公众号app_secret
          $base = new WxBase($appId, $appSecret);
    • Order 微信订单操作类

      • 示例

          $wx_order = new Order($base);
          $mchId = "your mch_id";     // 商户号id
          $key = "your key";  // 商户密钥
          $wx_order->setMchID($mchId)->setKey($key);  // 设置密钥和商户号
          
          // 调用统一下单接口
          $openid = 'your openid';    // 用户openid
          $trade_sn = 'your trade_sn';    // 商户订单号
          $price = '1.00';    // 订单价格
          $notify = 'your notify';    // 回调地址
          $res = $wx_order->unifiedOrder($openid, $trade_sn, $price, $notify);
      
          // 调用企业付款 
          $wx_order = new Order($base);
          $cert = 'your cert';    // cert 证书路径
          $ssl_key = 'your ssl_key';  // ssl_key 证书路径
          $openid = 'your openid';    // 用户openid
          $trade_sn = 'your trade_sn';    // 商户订单号
          $price = '1.00';    // 提现金额
          $desc = '提现描述';
          $wx_order->setMchID($mchId)->setKey($key)->setCert($cert)->setSslKey($ssl_key);
          $res = $wx_order->payToUser($openid, $trade_sn, $price, $desc);
    • TemplateMessage 微信消息操作类

      • 示例

          $message = new TemplateMessage($base);
          $openid = 'user openid';    // 接收消息的用户openid
          $template_id = 'your template_id';  // 消息模板id
          $params = [];   // 消息模板需传递的参数数组
          $page = 'your xcx page url';    // 消息跳转地址
          $result = $message->sendXcxMessage($openid, $template_id, $params, $page);
  • Kind 工具类集合

    • AuthManage 权限相关的类

      • JwtManage jwt验证类
        • 示例

            $publicKey = 'your public_key'; // 公钥
            $privateKey = 'your private_key';   // 私钥
            $jwt = new JwtManage($publicKey, $privateKey);
            // 加密
            $payload = array('user_id' => 1234, 'expire' => time() + 100);
            $token = $jwt->encode($payload);
            // 解密
            $result = $jwt->decode($token);