PHP code example of larva / think-wechat

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

    

larva / think-wechat example snippets




namespace app\controller;

use think\Controller;

class Wechat extends Controller
{

    public function index()
    {
        //    先初始化微信
        $app = app('wechat.official_account');
        $app->server->push(function($message){
            return 'hello,world';
        });
        $app->server->serve()->send();
    }
}

use Larva\Wechat\Wechat;

$officialAccount = Wechat::officialAccount();  // 公众号
$work = Wechat::work(); // 企业微信
$payment = Wechat::payment(); // 微信支付
$openPlatform = Wechat::openPlatform(); // 开放平台
$miniProgram = Wechat::miniProgram(); // 小程序
$openWork = Wechat::openWork(); // 企业微信第三方服务商
$microMerchant = Wechat::microMerchant(); // 小微商户

$officialAccount = Wechat::officialAccount('test'); // 公众号