PHP code example of rdisme / wechat

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

    

rdisme / wechat example snippets


use Rwechat\Offiaccount\AccessToken;

$wxconfig = array(
    'appid' => '22222',
    'appsecret' => '3333'
);

$token = new AccessToken($wxconfig);
$token = $token->send();

var_dump($token);

use Rwechat\Offiaccount\OauthAcceccToken;

$wxconfig = array(
    'appid' => '22222',
    'appsecret' => '3333'
);

// 授权第一步回跳带过来的code参数
$code = 'eeeeee';

$oauth = new OauthAcceccToken($wxconfig);
$access_token = $oauth->set_code($code)->send();

var_dump($access_token);

use Rwechat\Offiaccount\UserInfo;

$token = '27_yPUlqMZwnBDDE8iuYZ_lXGsfjvM1oDOKDF6TQm13Fj5WdKPIUAx1l8J54bRoxjtDSoMNdX7vIZAqGOrrPSi4_Gaa0HV5v1EQKuRq0ua_EvwbS9fD-aJT2OHb-fqMNX5yfZ6iKtF7j0dFs4JWJKCaADAUVN';
$openid = 'oUCzdt94RI5zuZcCwMeRjswX_UqM';

$user = new UserInfo();
$info = $user->set_token($token)
        ->set_openid($openid)->send();

var_dump($info);