, (*1)
MIT License, (*2)
WechatBundle
PHP Bundle for WeChat. By developing applications, it is often required to call WeChat services ( like get all connected user information, authorize an user to connect... etc... ). The goal of this bundle is to group them all., (*3)
The latest version of the bundle can handle :
- get all the necessary token for both of Oauth2 and Wechat JS API communication
- authorize an user to connect by checking Wechat account
- get current connected user WeChat information ( nichname, location, image... ), (*4)
Note : if you want be able to handle WeChat wall/friends sharing features, please use my other JavaScript project WechatJS with the current bundle., (*5)
Note : bundle development ongoing tasks are all availables in this Github issues section., (*6)
Installation
The latest version of the bundle can be downloaded through Composer :, (*7)
"require": {
"jean553/wechat-bundle": "dev-master"
}
Use
Use the bundle in your project :, (*8)
use jean553\WechatBundle\Services\WechatService;
Connect to the WeChat authentication service OAuth2. Use your application id ( appid ) and secret passphrase ( secret ) available on your WeChat Public Account ( https://mp.weixin.qq.com/ )., (*9)
$wechatService = new WechatService();
$authentication = $wechatService->authorize(
$appid,
$secret
);
if(!$authentication) {
return new Response('WeChat connection error.');
}
Get the current user information., (*10)
$user = $wechatService->getUserInformation();
$user is an array which contains the following items :
- openid : user WeChat openid
- nickname : WeChat nickname of the user
- sex
- language
- city
- province
- country
- headimgurl : absolute path of the user profile picture
- privilege, (*11)
Run the tests
bin/phpunit jean553/WechatBundle