PHP code example of code-lives / byte

1. Go to this page and download the library: Download code-lives/byte 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/ */

    

code-lives / byte example snippets


composer 



//引入命名空间
use Applet\Assemble\Byte;

$pay= Byte::init($config)->set("订单号","金额","描述","描述")->getParam();


$data= Byte::init($config)->getToken();

$code="";
$anonymous_code="";//可以不传
$data= Byte::init($config)->getOpenid($code,$anonymous_code);

$data= Byte::init($config)->decryptPhone($session_key, $iv, $encryptedData);
echo $phone['phoneNumber'];

$data = Byte::init($config)->findOrder("订单号");

$data = Byte::init($config)->settle($order);

$order = [
        'out_order_no' => '',
        'out_refund_no' => time() . 'refund',
        'reason' => '就想退款,咋滴',
        'refund_amount' => 1, //退款金额
    ];
$data= Byte::init($config)->applyOrderRefund($order);

$data = [
        'tpl_id' =>  "模版id",
        "open_id" => $parm['openid'],
        'data' => [
            '律师' => "张三",
            "回复时间" => date('Y-m-d H:i:s', time()),
            "回复内容" => "我回复你啦",
        ],
        "page" => "pages/index/index",
    ];
$data= Byte::init($config)->sendMsg($data,$token);


$byte = Byte::init($config);
$status = $byte->notifyCheck(); //验证
if ($status) {
    $orderSn = $byte->getNotifyOrder(); //订单数据$orderSn['msg']['cp_orderno'] $orderSn['msg']['seller_uid']
    switch ($orderSn['type']) {
        case 'payment': // 支付相关回调
            /**
             *业务处理
            */
            echo json_encode(['err_no' => 0, 'err_tips' => 'success']);exit; // 操作成功需要给头条返回的信息
            break;
        case 'refund': // 退款相关回调
            /**
             *业务处理
            */
            echo json_encode(['err_no' => 0, 'err_tips' => 'success']);exit; // 操作成功需要给头条返回的信息
            break;
        case 'settle': // 分账相关回调
            /**
             *业务处理
            */
            echo json_encode(['err_no' => 0, 'err_tips' => 'success']);exit; // 操作成功需要给头条返回的信息
            break;
        default: // 未知数据
            return '数据异常';
    }
}