PHP code example of code-lives / kuaishou

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


composer 


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

// 小程序下单
$pay= Kuaishou::init($config)->set("订单号","金额","描述",'openid', 'access_token')->getParam();


$code="";
$data= Kuaishou::init($config)->getToken();

$code="";
$data= Kuaishou::init($config)->getOpenid($code);

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

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

$orders = [
        'out_order_no' => $order['out_order_no'],
        'out_refund_no' => $order['out_refund_no'],
        'reason' => $order['reason'],
        'attach' => $order['attach'],
    ];
$data= Kuaishou::init($config)->applyOrderRefund($order);

//注意 需要设置回调 notify_url  在config 设置 settle_url 如果没有 默认为 notify_url
$orders = [
        'out_order_no' => $order['out_order_no'],
        'out_settle_no' => $order['out_settle_no'],
        'reason' => $order['reason'],
        'attach' => $order['attach'],
    ];
$data= Kuaishou::init($config)->settle($order,$access_token);


$order = [
        'out_biz_order_no' => '',
        'out_order_no' => '',
        'open_id' => '',
        'order_create_time' => time(),
        'order_status' => 6,
        'order_path' => '',
        'product_cover_img_id' =>'',
    ];
$data = Kuaishou::init($config)->synchronousOrder($order, $token);

$data = Kuaishou::init($config)->imgUpload('图片路径', $token);

$data = [
    "open_id" => "",
    "tpl_id" => "",
    "page" => "pages/index/index",
    "data" => [
        'key1' =>  "第一个",
        'key2' =>  "第二个",
        'key3' =>  "第三个",
    ]
];
$data= Kuaishou::init($config)->sendMsg($data,$token);
$data=[
    "err_no" => 1001,
    "err_tips" => "该用户未订阅"
]

$pay = Kuaishou::init($config);
$status = $pay->notifyCheck(); //验证
if ($status) {
    $order = $pay->getNotifyOrder(); //订单数据
    //$order['data']['out_order_no']//平台订单号
    echo json_encode(['result' => 1, 'message_id' => $order['message_id']]);exit;
}