PHP code example of littlemo / wechat

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

    

littlemo / wechat example snippets


use littlemo\wechat\Class;

$Class = new Class($appid , $secret, $mchid , $key , $certPath, $keyPath );


use littlemo\wechat\Class;
use littlemo\wechat\core\LWechatException;

$Class = new Class($appid, $appkey);

$result = $Class->token();

if ($result) {
    echo '获取Access token成功';
    $token = $Class->getMessage();
} else {
    echo "获取Access token失败";
    $errorMsg = $Class->getErrorMsg();
}

try{
    $data = $Class->token()
}catch(LWechatException $e){
    print_r('错误代码:'.$e->getCode());
    print_r('错误提示:'.$e->getMessage());
    print_r('完整的内容:'.json_encode($e->getData()));
};

//查询完整的回调消息
$intactMsg = $Class->getIntactMsg();