jean553 / wechat-bundle
Wechat authentication/profile management bundle
Installs: 46
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 3
Type:symfony-bundle
Requires
- php: >=5.3.2
- guzzlehttp/guzzle: ~5.0
Requires (Dev)
- phpunit/phpunit: ~4.4
- symfony/config: ~2.5
- symfony/dependency-injection: ~2.5
- symfony/http-kernel: ~2.5
- symfony/validator: ~2.5
- symfony/yaml: ~2.5
This package is not auto-updated.
Last update: 2024-05-15 06:42:13 UTC
README
MIT License
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.
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... )
Note : if you want be able to handle WeChat wall/friends sharing features, please use my other JavaScript project WechatJS with the current bundle.
Note : bundle development ongoing tasks are all availables in this Github issues section.
Installation
The latest version of the bundle can be downloaded through Composer :
"require": {
"jean553/wechat-bundle": "dev-master"
}
Use
Use the bundle in your project :
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/ ).
$wechatService = new WechatService();
$authentication = $wechatService->authorize(
$appid,
$secret
);
if(!$authentication) {
return new Response('WeChat connection error.');
}
Get the current user information.
$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
Run the tests
bin/phpunit jean553/WechatBundle