PHP code example of deloz / wechat-bridge

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

    

deloz / wechat-bridge example snippets



$wechat = new WeChatBridge('YOUR_APP_ID', 'YOUR_APP_SECRET');

// Get the user's profile information
$userId = 'USER_OPENID_HERE';
$response = $wechat->get('/cgi-bin/user/info', [
    'openid' => $userId,
    'lang' => 'zh_CN'
]);

if (isset($response['errcode'])) {
    echo 'Error: ' . $response['errmsg'];
} else {
    echo 'User profile information:';
    echo '<ul>';
    echo '<li>Nickname: ' . $response['nickname'] . '</li>';
    echo '<li>Country: ' . $response['country'] . '</li>';
    echo '<li>Province: ' . $response['province'] . '</li>';
    echo '<li>City: ' . $response['city'] . '</li>';
    echo '</ul>';
}