WeOpenDeveloper
修正接口链接
WeOpenDeveloper is a WeChat open platform service development tool that can manage public accounts based on WeChatDeveloper. For more functions, please refer to the documentation below.
PHP development technology exchange (QQ group 513350915)
WeChatDeveloper is based on the official interface package. Before doing WeChat development, you must first read the WeChat official documentation.
- WeChat official documentation: http://mp.weixin.qq.com/wiki
- Open platform documentation: https://open.weixin.qq.com
- Merchant payment documentation: https://pay.weixin.qq.com/wiki/doc/api/index.html
There is also help material prepared for WeChatDeveloper for reference.
- WeChatDeveloper documentation: http://www.kancloud.cn/zoujingli/wechat-developer
WeOpenDeveloper is an open source project, allowing it to be used anywhere without any restrictions. Forks are welcome.
- GitHub hosting address: https://github.com/zoujingli/WeOpenDeveloper
- OSChina hosting address: http://git.oschina.net/zoujingli/WeOpenDeveloper
For more development, please refer to the project ThinkService. This project has been integrated with the ThinkAdmin + ThinkService combination.
# 首次安装 线上版本(稳定)
composer require zoujingli/weopen-developer
# 首次安装 开发版本
composer require zoujingli/weopen-developer dev-master
# 更新 WeChatDeveloper
composer update zoujingli/weopen-developer
// 配置参数(可以公众号服务平台获取)
$ config = [
' component_appid ' => ' wx4e63e993e222df8d ' ,
' component_token ' => ' P8QHTIxpBEq88IrxatqhgpBm2OAQROkI ' ,
' component_appsecret ' => ' 7cfa1afa87a41e2ea3445cea015c0974 ' ,
' component_encodingaeskey ' => ' L5uFIa0U6KLalPyXckyqoVIJYLhsfrg8k9YzybZIHsx ' ,
];
// 注册授权公众号 AccessToken 处理
$ config [ ' GetAccessTokenCallback ' ] = function ( $ authorizer_appid ) use ( $ config ) {
$ open = new WeOpen Service ( $ config );
$ authorizer_refresh_token = '' ; // 通过$authorizer_appid从数据库去找吧,在授权绑定的时候获取
$ result = $ open -> refreshAccessToken ( $ authorizer_appid , $ authorizer_refresh_token );
if ( empty ( $ result [ ' authorizer_access_token ' ])) {
throw new WeChat Exceptions InvalidResponseException ( $ result [ ' errmsg ' ], ' 0 ' );
}
$ data = [
' authorizer_access_token ' => $ result [ ' authorizer_access_token ' ],
' authorizer_refresh_token ' => $ result [ ' authorizer_refresh_token ' ],
];
// 需要把$data记录到数据库
return $ result [ ' authorizer_access_token ' ];
};
try {
// 实例公众号服务接口
$ server = new WeOpen Service ( $ config );
// 获取并更新Ticket推送
if (!( $ data = $ server -> getComonentTicket ())) {
return " Ticket event handling failed. " ;
}
} catch ( Exception $ e ) {
// 出错啦,处理下吧
echo $ e -> getMessage () . PHP_EOL ;
}
try {
// 实例公众号服务接口
$ open = new WeOpen Service ( $ config );
// 获取公众号接口操作实例
$ wechat = $ open -> instance ( ' User ' , ' wx60a43dd8161666d4 ' );
// 获取公众号粉丝列表
$ list = $ wechat -> getUserList ();
var_export ( $ list );
} catch ( Exception $ e ) {
// 出错啦,处理下吧
echo $ e -> getMessage () . PHP_EOL ;
}
MIT
license and can be used by anyone, anywhere without restrictions.