PHP code example of luweiss / wechat

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

    

luweiss / wechat example snippets




$wechat = new \luweiss\Wechat\Wechat();
$accessToken = $wechat->getAccessToken;



$wechatPay = new \luweiss\Wechat\WechatPay();
$res = $wechatPay->unifiedOrder();

$wechat = new \luweiss\Wechat\Wechat();
$tid = 434;     // 模板标题 id,可通过接口获取,也可登录小程序后台查看获取
$kidList = [6, 5, 9, 1];      // 开发者自行组合好的模板关键词列表,可以通过 `getTemplateKeywords` 方法获取
$sceneDesc = '下单成功通知';    // 服务场景描述,非必填

$wechatSubscribe = new \luweiss\Wechat\WechatSubscribe($wechat);
$res = $wechatSubscribe->addTemplate($tid, $kidList, $sceneDesc);