| Package Data | |
|---|---|
| Maintainer Username: | hotfermat | 
| Maintainer Contact: | xxywdl@163.com (xxy) | 
| Package Create Date: | 2015-02-27 | 
| Package Last Update: | 2015-02-27 | 
| Language: | PHP | 
| License: | MIT | 
| Last Refreshed: | 2025-10-30 03:04:50 | 
| Package Statistics | |
|---|---|
| Total Downloads: | 26 | 
| Monthly Downloads: | 0 | 
| Daily Downloads: | 0 | 
| Total Stars: | 7 | 
| Total Watchers: | 3 | 
| Total Forks: | 6 | 
| Total Open Issues: | 0 | 
CorporationWechat SDK for Laravel 4 微信企业号SDK
#微信企业号公众平台 Laravel SDK
##使用帮助
###0、说明
用 Laravel Facade 封装了binsee/wechat-php-sdk,目前只添加了 wechat.class 官方API类库,尽量做到及时更新,还未做全部测试,欢迎提交issue。
###1、安装
请先确认已经安装Composer. 编辑 composer.json 文件,然后加入 xxy/wechat.
"require": {
    "xxy/wechat": "dev-master"
}
更新包 composer update 。
需要添加以下服务到系统。
打开 app/config/app.php , 在'providers' 下添加:
'xxy\Wechat\WechatServiceProvider',
在'aliases' 下添加:
'Wechat' => 'xxy\Wechat\Facades\Wechat',
执行 php artisan config:publish xxy/wechat ,然后修改 app/config/packages/xxy/wechat 中的配置文件 wechat.php 。
把微信企业号的 'token', 'encodingaeskey', 'appid', 'appsecret' ,'agentid'改为对应的。
##2、使用示例
// 获取用户列表
Route::get('/users', function(){
    return Wechat::getUserList();
});
// 回复文本消息
Route::post('/', function(){
    $weObj = new xxy\Wechat\Wechat();
    $weObj->valid(); //注意, 企业号与普通公众号不同,必须打开验证,不要注释掉
    $type = $weObj->getRev()->getRevType();
    $weObj->text("hello, it's wechat")->reply();
});
调用官方API,具有更灵活的消息分类响应方式,支持链式调用操作 ;
scancode_push或scancode_waitmsg 返回数组array ('ScanType'=>'qrcode','ScanResult'=>'123123')pic_sysphoto或pic_photo_or_album或pic_weixin 数组结构见php文件内方法说明location_select 数组结构见php文件内方法说明////消息类型,使用实例调用getRevType()方法取得
    const MSGTYPE_TEXT = 'text';
    const MSGTYPE_IMAGE = 'image';
    const MSGTYPE_LOCATION = 'location';
    const MSGTYPE_LINK = 'link';    //暂不支持
    const MSGTYPE_EVENT = 'event';
    const MSGTYPE_MUSIC = 'music';    //暂不支持
    const MSGTYPE_NEWS = 'news';
    const MSGTYPE_VOICE = 'voice';
    const MSGTYPE_VIDEO = 'video';
////事件类型,使用实例调用getRevEvent()方法取得
    const EVENT_SUBSCRIBE = 'subscribe';       //订阅
    const EVENT_UNSUBSCRIBE = 'unsubscribe';   //取消订阅
    const EVENT_LOCATION = 'LOCATION';         //上报地理位置
    const EVENT_ENTER_AGENT = 'enter_agent';   //用户进入应用
    const EVENT_MENU_VIEW = 'VIEW';                     //菜单 - 点击菜单跳转链接
    const EVENT_MENU_CLICK = 'CLICK';                   //菜单 - 点击菜单拉取消息
    const EVENT_MENU_SCAN_PUSH = 'scancode_push';       //菜单 - 扫码推事件(客户端跳URL)
    const EVENT_MENU_SCAN_WAITMSG = 'scancode_waitmsg'; //菜单 - 扫码推事件(客户端不跳URL)
    const EVENT_MENU_PIC_SYS = 'pic_sysphoto';          //菜单 - 弹出系统拍照发图
    const EVENT_MENU_PIC_PHOTO = 'pic_photo_or_album';  //菜单 - 弹出拍照或者相册发图
    const EVENT_MENU_PIC_WEIXIN = 'pic_weixin';         //菜单 - 弹出微信相册发图器
    const EVENT_MENU_LOCATION = 'location_select';      //菜单 - 弹出地理位置选择器
    const EVENT_SEND_MASS = 'MASSSENDJOBFINISH';        //发送结果 - 高级群发完成
    const EVENT_SEND_TEMPLATE = 'TEMPLATESENDJOBFINISH';//发送结果 - 模板消息发送结果
$token
0获取全部员工,1获取已关注成员列表,2获取禁用成员列表,4获取未关注成员列表。status可叠加
##6、环境 PHP >= 5.4 Laravel >= 4.2
##7、License
This is free software distributed under the terms of the MIT license
感谢 binsee/wechat-php-sdk 和 atan/wechat