PHP code example of oywenjiao / php-tool-kit

1. Go to this page and download the library: Download oywenjiao/php-tool-kit library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

oywenjiao / php-tool-kit example snippets


            $obj = new Baidu();
            $response = $obj->query('YT123456', '圆通速递');
        

            $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);
        

            $appId = 'your appid';  // 公众号appid
            $appSecret = 'your appSecret';  // 公众号app_secret
            $base = new WxBase($appId, $appSecret);
        

            $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);
        

            $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);
        

                $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);