Browse Source

1、添加qywechat.class.php 专供企业号使用(含Thinkphp版)
目前已经实现所有开放的企业号功能调用,包括数据加密
调用接口已经全部在README.md文档内登记
2、添加qyerrCode.php 同样专供企业号使用
用于换取企业号全局返回码的中文说明
3、添加qydemo.php 作为企业号的调用demo
4、修补wechat.class.php的getRevPic()接口,加上了遗漏的picurl键值
5、对于wechat.class.php增加以下几个被动回复方法,不知道以前为什么没有
image($mediaid='')
voice($mediaid='')
video($mediaid='',$title,$description)
6、将createMenu($data)的说明进行更新,增加了最新菜单类型的说明

binsee 10 years ago
parent
commit
0e30a7b5a9
7 changed files with 4024 additions and 56 deletions
  1. 117 0
      README.md
  2. 118 28
      Thinkphp/Wechat.class.php
  3. 1735 0
      Thinkphp/qywechat.class.php
  4. 29 0
      qydemo.php
  5. 179 0
      qyerrCode.php
  6. 1726 0
      qywechat.class.php
  7. 120 28
      wechat.class.php

+ 117 - 0
README.md

@@ -173,6 +173,97 @@ else
 
 ```
 
+ 5. qywechat.class.php
+
+## 企业号API类库
+调用官方API,具有更灵活的消息分类响应方式,支持链式调用操作 ; 
+
+## 主要功能 
+- 接入验证 (初级权限)
+- 自动回复(文本、图片、语音、视频、音乐、图文)
+- 菜单操作(查询、创建、删除)
+- 部门管理(创建、更新、删除、获取列表)
+- 成员管理(创建、更新、删除、获取成员信息,获取部门成员列表)
+- 标签管理(创建、更新、删除、获取成员、添加成员、删除成员)
+- 媒体文件管理(上传、获取)
+- 二次验证
+- OAuth2(生成授权url、获取成员信息)
+
+
+## 初始化动作 
+```php
+$options = array(
+  'token'=>'tokenaccesskey', //填写应用接口的Token
+  'encodingaeskey'=>'encodingaeskey', //填写加密用的EncodingAESKey
+  'appid'=>'wxdk1234567890', //填写高级调用功能的app id
+  'appsecret'=>'xxxxxxxxxxxxxxxxxxx', //填写高级调用功能的密钥
+  'agentid'=>'1', //应用的id
+  'debug'=>false, //调试开关
+  '_logcallback'=>'logg', //调试输出方法,需要有一个string类型的参数
+);
+ $weObj = new Wechat($options); //创建实例对象
+ //TODO:调用$weObj各实例方法
+
+```
+
+## 被动接口方法:   
+* valid() 验证连接
+* 
+* getRev() 获取微信服务器发来信息(不返回结果)
+* getRevData() 返回微信服务器发来的信息(数组)
+* getRevPostXml() 返回微信服务器发来的原始加密xml信息
+* getRevFrom()  返回消息发送者的userid
+* getRevTo()  返回消息接收者的id(即公众号id,一般与等同appid一致)
+* getRevAgentID() 返回接收消息的应用id
+* getRevType() 返回接收消息的类型
+* getRevID() 返回消息id
+* getRevCtime() 返回消息发送事件
+* getRevContent() 返回消息内容正文(文本型消息)
+* getRevPic() 返回图片信息(图片型信息) 返回数组{'mediaid'=>'','picurl'=>''}
+* getRevGeo() 返回地理位置(位置型信息) 返回数组{'x'=>'','y'=>'','scale'=>'','label'=>''}
+* getRevEventGeo() 返回事件地理位置(事件型信息) 返回数组{'x'=>'','y'=>'','precision'=>''}
+* getRevEvent() 返回事件类型(事件型信息) 返回数组{'event'=>'','key'=>''}
+* getRevVoice() 返回语音信息(语音型信息) 返回数组{'mediaid'=>'','format'=>''}
+* getRevVoice() 返回语音信息(语音型信息) 返回数组{'mediaid'=>'','format'=>''}
+* getRevVideo() 返回视频信息(视频型信息) 返回数组{'mediaid'=>'','thumbmediaid'=>''}
+* 
+* text($text) 设置文本型消息,参数:文本内容
+* image($mediaid) 设置图片型消息,参数:图片的media_id
+* voice($mediaid) 设置语音型消息,参数:语音的media_id
+* video($mediaid='',$title,$description) 设置视频型消息,参数:视频的media_id、标题、摘要
+* news($newsData) 设置图文型消息,参数:数组。数组结构见php文件内方法说明
+* image($mediaid) 设置图片型消息,参数:图片的media_id
+* Message($msg = '',$append = false) 设置发送的消息(一般不需要调用这个方法)
+* reply() 将已经设置好的消息,回复给微信服务器
+
+## 主动接口方法:
+* checkAuth($appid='',$appsecret='') 通用auth验证方法,也用来换取ACCESS_TOKEN
+* resetAuth($appid='') 清除记录的ACCESS_TOKEN
+* createMenu($data,$agentid='') 创建菜单,参数:菜单内容数组,要创建菜单应用id
+* getMenu($agentid='') 获取菜单内容,参数:要获取菜单内容的应用id
+* deleteMenu($agentid='') 删除菜单,参数:要删除菜单的应用id
+* uploadMedia($data, $type) 上传媒体文件,参数请看php文件内方法说明
+* getMedia($media_id) 根据媒体文件ID获取媒体文件,参数:媒体id
+* createDepartment($data) 创建部门,参数: array("name"=>"邮箱产品组","parentid"=>"1")
+* updateDepartment($data) 更新部门,参数: array("id"=>"1","name"=>"邮箱产品组")
+* deleteDepartment($id) 删除部门,参数:要删除的部门id
+* getDepartment() 获取部门列表,返回部门数组
+* createUser($data) 创建成员,参数请看php文件内方法说明
+* updateUser($data) 更新成员,参数请看php文件内方法说明
+* deleteUser($userid) 删除成员,参数:员工UserID
+* getUserInfo($userid) 获取成员信息,参数:员工UserID
+* getUserList($department_id,$fetch_child=0,$status=0) 获取部门成员,参数:部门id,是否递归获取子部门,获取类型。
+> 0获取全部员工,1获取已关注成员列表,2获取禁用成员列表,4获取未关注成员列表。status可叠加
+* createTag($data) 创建标签,参数:array("tagname" => "UI")
+* updateTag($data) 更新标签,参数:array("tagid" => "1","tagname" => "UI")
+* deleteTag($tagid) 删除标签,参数:标签TagID
+* getTag($tagid) 获取标签成员,参数:标签TagID
+* addTagUser($data) 增加标签成员,参数请看php文件内方法说明
+* delTagUser($data) 删除标签成员,参数请看php文件内方法说明
+* sendMessage($data) 主动发送信息接口,参数请看php文件内方法说明
+* authSucc($code,$userid) 二次验证,参数: 员工授权获取到的code,$userid
+* getOauthRedirect($callback,$state='STATE',$scope='snsapi_base') 组合授权跳转接口url
+
 
 官方Wechat调用示例:
 --------  
@@ -263,6 +354,32 @@ switch($type) {
 ```
 HTML部分请看test/test3.php, 主要是定时ajax查询是否已经授权成功
 
+企业号API类库调用示例:
+```php
+//test1.php
+include "wechat.class.php";
+$options = array(
+        'token'=>'9Ixxxxxxx',	//填写应用接口的Token
+        'encodingaeskey'=>'d4o9WVg8sxxxxxxxxxxxxxxxxxxxxxx',//填写加密用的EncodingAESKey
+        'appid'=>'wxa07979baxxxxxxxx',	//填写高级调用功能的appid
+);
+$weObj = new Wechat($options);
+$weObj->valid(); //注意, 企业号与普通公众号不同,必须打开验证,不要注释掉
+$type = $weObj->getRev()->getRevType();
+switch($type) {
+	case Wechat::MSGTYPE_TEXT:
+			$weObj->text("hello, I'm wechat")->reply();
+			exit;
+			break;
+	case Wechat::MSGTYPE_EVENT:
+			break;
+	case Wechat::MSGTYPE_IMAGE:
+			break;
+	default:
+			$weObj->text("help info")->reply();
+}
+```
+
 License
 -------
 This is licensed under the GNU LGPL, version 2.1 or later.   

+ 118 - 28
Thinkphp/Wechat.class.php

@@ -301,7 +301,10 @@ class Wechat
 	 */
 	public function getRevPic(){
 		if (isset($this->_receive['PicUrl']))
-			return $this->_receive['PicUrl'];
+			return array(
+				'mediaid'=>$this->_receive['MediaId'],
+				'picurl'=>(string)$this->_receive['PicUrl'],    //防止picurl为空导致解析出错
+			);
 		else 
 			return false;
 	}
@@ -630,6 +633,67 @@ class Wechat
 		$this->Message($msg);
 		return $this;
 	}
+	/**
+	 * 设置回复消息
+	 * Examle: $obj->image('media_id')->reply();
+	 * @param string $mediaid
+	 */
+	public function image($mediaid='')
+	{
+		$FuncFlag = $this->_funcflag ? 1 : 0;
+		$msg = array(
+			'ToUserName' => $this->getRevFrom(),
+			'FromUserName'=>$this->getRevTo(),
+			'MsgType'=>self::MSGTYPE_IMAGE,
+			'Image'=>array('MediaId'=>$mediaid),
+			'CreateTime'=>time(),
+			'FuncFlag'=>$FuncFlag
+		);
+		$this->Message($msg);
+		return $this;
+	}
+	/**
+	 * 设置回复消息
+	 * Examle: $obj->voice('media_id')->reply();
+	 * @param string $mediaid
+	 */
+	public function voice($mediaid='')
+	{
+		$FuncFlag = $this->_funcflag ? 1 : 0;
+		$msg = array(
+			'ToUserName' => $this->getRevFrom(),
+			'FromUserName'=>$this->getRevTo(),
+			'MsgType'=>self::MSGTYPE_IMAGE,
+			'Voice'=>array('MediaId'=>$mediaid),
+			'CreateTime'=>time(),
+			'FuncFlag'=>$FuncFlag
+		);
+		$this->Message($msg);
+		return $this;
+	}
+	/**
+	 * 设置回复消息
+	 * Examle: $obj->video('media_id','title','description')->reply();
+	 * @param string $mediaid
+	 */
+	public function video($mediaid='',$title,$description)
+	{
+		$FuncFlag = $this->_funcflag ? 1 : 0;
+		$msg = array(
+			'ToUserName' => $this->getRevFrom(),
+			'FromUserName'=>$this->getRevTo(),
+			'MsgType'=>self::MSGTYPE_IMAGE,
+			'Video'=>array(
+			        'MediaId'=>$mediaid,
+			        'Title'=>$mediaid,
+			        'Description'=>$mediaid,
+			),
+			'CreateTime'=>time(),
+			'FuncFlag'=>$FuncFlag
+		);
+		$this->Message($msg);
+		return $this;
+	}
 	
 	/**
 	 * 设置回复音乐
@@ -861,33 +925,59 @@ class Wechat
 	 * 创建菜单
 	 * @param array $data 菜单数组数据
 	 * example:
-		  {
-		     "button":[
-		     {	
-		          "type":"click",
-		          "name":"今日歌曲",
-		          "key":"MENU_KEY_MUSIC"
-		      },
-		      {
-		           "type":"view",
-		           "name":"歌手简介",
-		           "url":"http://www.qq.com/"
-		      },
-		      {
-		           "name":"菜单",
-		           "sub_button":[
-		            {
-		               "type":"click",
-		               "name":"hello word",
-		               "key":"MENU_KEY_MENU"
-		            },
-		            {
-		               "type":"click",
-		               "name":"赞一下我们",
-		               "key":"MENU_KEY_GOOD"
-		            }]
-		       }]
-		 }
+     * 	array (
+     * 	    'button' => array (
+     * 	      0 => array (
+     * 	        'name' => '扫码',
+     * 	        'sub_button' => array (
+     * 	            0 => array (
+     * 	              'type' => 'scancode_waitmsg',
+     * 	              'name' => '扫码带提示',
+     * 	              'key' => 'rselfmenu_0_0',
+     * 	              'sub_button' => ''
+     * 	            ),
+     * 	            1 => array (
+     * 	              'type' => 'scancode_push',
+     * 	              'name' => '扫码推事件',
+     * 	              'key' => 'rselfmenu_0_1',
+     * 	              'sub_button' => ''
+     * 	            ),
+     * 	        ),
+     * 	      ),
+     * 	      1 => array (
+     * 	        'name' => '发图',
+     * 	        'sub_button' => array (
+     * 	            0 => array (
+     * 	              'type' => 'pic_sysphoto',
+     * 	              'name' => '系统拍照发图',
+     * 	              'key' => 'rselfmenu_1_0',
+     * 	              'sub_button' => ''
+     * 	            ),
+     * 	            1 => array (
+     * 	              'type' => 'pic_photo_or_album',
+     * 	              'name' => '拍照或者相册发图',
+     * 	              'key' => 'rselfmenu_1_1',
+     * 	              'sub_button' => ''
+     * 	            )
+     * 	        ),
+     * 	      ),
+     * 	      2 => array (
+     * 	        'type' => 'location_select',
+     * 	        'name' => '发送位置',
+     * 	        'key' => 'rselfmenu_2_0',
+     * 	        'sub_button' => ''
+     * 	      ),
+     * 	    ),
+     * 	)
+     * type可以选择为以下几种,其中5-8除了收到菜单事件以外,还会单独收到对应类型的信息。
+     * 1、click:点击推事件
+     * 2、view:跳转URL
+     * 3、scancode_push:扫码推事件
+     * 4、scancode_waitmsg:扫码推事件且弹出“消息接收中”提示框
+     * 5、pic_sysphoto:弹出系统拍照发图
+     * 6、pic_photo_or_album:弹出拍照或者相册发图
+     * 7、pic_weixin:弹出微信相册发图器
+     * 8、location_select:弹出地理位置选择器
 	 */
 	public function createMenu($data){
 		if (!$this->access_token && !$this->checkAuth()) return false;

File diff suppressed because it is too large
+ 1735 - 0
Thinkphp/qywechat.class.php


+ 29 - 0
qydemo.php

@@ -0,0 +1,29 @@
+<?php
+include "qywechat.class.php";
+
+function logg($text){
+    file_put_contents('./log.txt',$text."\r\n\r\n",FILE_APPEND);
+};
+
+$options = array(
+        'token'=>'9xxxxxxxxxxxx',	//填写应用接口的Token
+        'encodingaeskey'=>'d4oxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',//填写加密用的EncodingAESKey
+        'appid'=>'wxa0xxxxxxxxxx',	//填写高级调用功能的appid
+        'debug'=>true,
+        'logcallback'=>'logg'
+
+);
+logg("GET参数为:\n".var_export($_GET,true));
+$weObj = new Wechat($options);
+$ret=$weObj->valid();
+if (!$ret) {
+	logg("验证失败!");
+	var_dump($ret);
+	exit;
+}
+$f = $weObj->getRev()->getRevFrom();
+$t = $weObj->getRevType();
+$d = $weObj->getRevData();
+$weObj->text("你好!来自星星的:".$f."\n你发送的".$t."类型信息:\n原始信息如下:\n".var_export($d,true))->reply();
+logg("-----------------------------------------");
+?>

+ 179 - 0
qyerrCode.php

@@ -0,0 +1,179 @@
+<?php
+/**
+ *	微信公众平台企业号PHP-SDK, 全局返回码类
+ *  @author  binsee <binsee@163.com>
+ *  @link https://github.com/binsee/wechat-php-sdk
+ *  @version 1.0
+ *  usage:
+ *      $ret=ErrCode::getErrText(40001);
+ *      if ($ret) 
+ *      	echo $ret;
+ *      else 
+ *          echo "未找到对应的内容";
+ */
+class ErrCode
+{
+	public static $errCode=array(
+	        '-1'=>'系统繁忙',
+	        '0'=>'请求成功',
+	        '40001'=>'获取access_token时AppSecret错误,或者access_token无效',
+	        '40002'=>'不合法的凭证类型',
+	        '40003'=>'不合法的UserID',
+	        '40004'=>'不合法的媒体文件类型',
+	        '40005'=>'不合法的文件类型',
+	        '40006'=>'不合法的文件大小',
+	        '40007'=>'不合法的媒体文件id',
+	        '40008'=>'不合法的消息类型',
+	        '40013'=>'不合法的corpid',
+	        '40014'=>'不合法的access_token',
+	        '40015'=>'不合法的菜单类型',
+	        '40016'=>'不合法的按钮个数',
+	        '40017'=>'不合法的按钮类型',
+	        '40018'=>'不合法的按钮名字长度',
+	        '40019'=>'不合法的按钮KEY长度',
+	        '40020'=>'不合法的按钮URL长度',
+	        '40021'=>'不合法的菜单版本号',
+	        '40022'=>'不合法的子菜单级数',
+	        '40023'=>'不合法的子菜单按钮个数',
+	        '40024'=>'不合法的子菜单按钮类型',
+	        '40025'=>'不合法的子菜单按钮名字长度',
+	        '40026'=>'不合法的子菜单按钮KEY长度',
+	        '40027'=>'不合法的子菜单按钮URL长度',
+	        '40028'=>'不合法的自定义菜单使用员工',
+	        '40029'=>'不合法的oauth_code',
+	        '40031'=>'不合法的UserID列表',
+	        '40032'=>'不合法的UserID列表长度',
+	        '40033'=>'不合法的请求字符,不能包含\uxxxx格式的字符',
+	        '40035'=>'不合法的参数',
+	        '40038'=>'不合法的请求格式',
+	        '40039'=>'不合法的URL长度',
+	        '40040'=>'不合法的插件token',
+	        '40041'=>'不合法的插件id',
+	        '40042'=>'不合法的插件会话',
+	        '40048'=>'url中包含不合法domain',
+	        '40054'=>'不合法的子菜单url域名',
+	        '40055'=>'不合法的按钮url域名',
+	        '40056'=>'不合法的agentid',
+	        '40057'=>'不合法的callbackurl',
+	        '40058'=>'不合法的红包参数',
+	        '40059'=>'不合法的上报地理位置标志位',
+	        '40060'=>'设置上报地理位置标志位时没有设置callbackurl',
+	        '40061'=>'设置应用头像失败',
+	        '40062'=>'不合法的应用模式',
+	        '40063'=>'红包参数为空',
+	        '40064'=>'管理组名字已存在',
+	        '40065'=>'不合法的管理组名字长度',
+	        '40066'=>'不合法的部门列表',
+	        '40067'=>'标题长度不合法',
+	        '40068'=>'不合法的标签ID',
+	        '40069'=>'不合法的标签ID列表',
+	        '40070'=>'列表中所有标签(用户)ID都不合法',
+	        '40071'=>'不合法的标签名字,标签名字已经存在',
+	        '40072'=>'不合法的标签名字长度',
+	        '40073'=>'不合法的openid',
+	        '40074'=>'news消息不支持指定为高保密消息',
+	        '41001'=>'缺少access_token参数',
+	        '41002'=>'缺少corpid参数',
+	        '41003'=>'缺少refresh_token参数',
+	        '41004'=>'缺少secret参数',
+	        '41005'=>'缺少多媒体文件数据',
+	        '41006'=>'缺少media_id参数',
+	        '41007'=>'缺少子菜单数据',
+	        '41008'=>'缺少oauth code',
+	        '41009'=>'缺少UserID',
+	        '41010'=>'缺少url',
+	        '41011'=>'缺少agentid',
+	        '41012'=>'缺少应用头像mediaid',
+	        '41013'=>'缺少应用名字',
+	        '41014'=>'缺少应用描述',
+	        '41015'=>'缺少Content',
+	        '41016'=>'缺少标题',
+	        '41017'=>'缺少标签ID',
+	        '41018'=>'缺少标签名字',
+	        '42001'=>'access_token超时',
+	        '42002'=>'refresh_token超时',
+	        '42003'=>'oauth_code超时',
+	        '42004'=>'插件token超时',
+	        '43001'=>'需要GET请求',
+	        '43002'=>'需要POST请求',
+	        '43003'=>'需要HTTPS',
+	        '43004'=>'需要接收者关注',
+	        '43005'=>'需要好友关系',
+	        '43006'=>'需要订阅',
+	        '43007'=>'需要授权',
+	        '43008'=>'需要支付授权',
+	        '43009'=>'需要认证',
+	        '43010'=>'需要处于企业模式',
+	        '43011'=>'需要企业授权',
+	        '44001'=>'多媒体文件为空',
+	        '44002'=>'POST的数据包为空',
+	        '44003'=>'图文消息内容为空',
+	        '44004'=>'文本消息内容为空',
+	        '45001'=>'多媒体文件大小超过限制',
+	        '45002'=>'消息内容超过限制',
+	        '45003'=>'标题字段超过限制',
+	        '45004'=>'描述字段超过限制',
+	        '45005'=>'链接字段超过限制',
+	        '45006'=>'图片链接字段超过限制',
+	        '45007'=>'语音播放时间超过限制',
+	        '45008'=>'图文消息超过限制',
+	        '45009'=>'接口调用超过限制',
+	        '45010'=>'创建菜单个数超过限制',
+	        '45015'=>'回复时间超过限制',
+	        '45016'=>'系统分组,不允许修改',
+	        '45017'=>'分组名字过长',
+	        '45018'=>'分组数量超过上限',
+	        '46001'=>'不存在媒体数据',
+	        '46002'=>'不存在的菜单版本',
+	        '46003'=>'不存在的菜单数据',
+	        '46004'=>'不存在的员工',
+	        '47001'=>'解析JSON/XML内容错误',
+	        '48002'=>'Api禁用',
+	        '50001'=>'redirect_uri未授权',
+	        '50002'=>'员工不在权限范围',
+	        '50003'=>'应用已停用',
+	        '50004'=>'员工状态不正确(未关注状态)',
+	        '50005'=>'企业已禁用',
+	        '60001'=>'部门长度不符合限制',
+	        '60002'=>'部门层级深度超过限制',
+	        '60003'=>'部门不存在',
+	        '60004'=>'父亲部门不存在',
+	        '60005'=>'不允许删除有成员的部门',
+	        '60006'=>'不允许删除有子部门的部门',
+	        '60007'=>'不允许删除根部门',
+	        '60008'=>'部门名称已存在',
+	        '60009'=>'部门名称含有非法字符',
+	        '60010'=>'部门存在循环关系',
+	        '60011'=>'管理员权限不足,(user/department/agent)无权限',
+	        '60012'=>'不允许删除默认应用',
+	        '60013'=>'不允许关闭应用',
+	        '60014'=>'不允许开启应用',
+	        '60015'=>'不允许修改默认应用可见范围',
+	        '60016'=>'不允许删除存在成员的标签',
+	        '60017'=>'不允许设置企业',
+	        '60102'=>'UserID已存在',
+	        '60103'=>'手机号码不合法',
+	        '60104'=>'手机号码已存在',
+	        '60105'=>'邮箱不合法',
+	        '60106'=>'邮箱已存在',
+	        '60107'=>'微信号不合法',
+	        '60108'=>'微信号已存在',
+	        '60109'=>'QQ号已存在',
+	        '60110'=>'部门个数超出限制',
+	        '60111'=>'UserID不存在',
+	        '60112'=>'成员姓名不合法',
+	        '60113'=>'身份认证信息(微信号/手机/邮箱)不能同时为空',
+	        '60114'=>'性别不合法',
+
+	);
+	
+	public static function getErrText($err) {
+		if (isset(self::$errCode[$err])) {
+			return self::$errCode[$err];
+		}else {
+		    return false;
+		};
+	}
+}
+
+?>

File diff suppressed because it is too large
+ 1726 - 0
qywechat.class.php


+ 120 - 28
wechat.class.php

@@ -296,7 +296,10 @@ class Wechat
 	 */
 	public function getRevPic(){
 		if (isset($this->_receive['PicUrl']))
-			return $this->_receive['PicUrl'];
+			return array(
+				'mediaid'=>$this->_receive['MediaId'],
+				'picurl'=>(string)$this->_receive['PicUrl'],    //防止picurl为空导致解析出错
+			);
 		else 
 			return false;
 	}
@@ -625,6 +628,69 @@ class Wechat
 		$this->Message($msg);
 		return $this;
 	}
+	/**
+	 * 设置回复消息
+	 * Examle: $obj->image('media_id')->reply();
+	 * @param string $mediaid
+	 */
+	public function image($mediaid='')
+	{
+		$FuncFlag = $this->_funcflag ? 1 : 0;
+		$msg = array(
+			'ToUserName' => $this->getRevFrom(),
+			'FromUserName'=>$this->getRevTo(),
+			'MsgType'=>self::MSGTYPE_IMAGE,
+			'Image'=>array('MediaId'=>$mediaid),
+			'CreateTime'=>time(),
+			'FuncFlag'=>$FuncFlag
+		);
+		$this->Message($msg);
+		return $this;
+	}
+	
+	/**
+	 * 设置回复消息
+	 * Examle: $obj->voice('media_id')->reply();
+	 * @param string $mediaid
+	 */
+	public function voice($mediaid='')
+	{
+		$FuncFlag = $this->_funcflag ? 1 : 0;
+		$msg = array(
+			'ToUserName' => $this->getRevFrom(),
+			'FromUserName'=>$this->getRevTo(),
+			'MsgType'=>self::MSGTYPE_IMAGE,
+			'Voice'=>array('MediaId'=>$mediaid),
+			'CreateTime'=>time(),
+			'FuncFlag'=>$FuncFlag
+		);
+		$this->Message($msg);
+		return $this;
+	}
+	
+	/**
+	 * 设置回复消息
+	 * Examle: $obj->video('media_id','title','description')->reply();
+	 * @param string $mediaid
+	 */
+	public function video($mediaid='',$title,$description)
+	{
+		$FuncFlag = $this->_funcflag ? 1 : 0;
+		$msg = array(
+			'ToUserName' => $this->getRevFrom(),
+			'FromUserName'=>$this->getRevTo(),
+			'MsgType'=>self::MSGTYPE_IMAGE,
+			'Video'=>array(
+			        'MediaId'=>$mediaid,
+			        'Title'=>$mediaid,
+			        'Description'=>$mediaid,
+			),
+			'CreateTime'=>time(),
+			'FuncFlag'=>$FuncFlag
+		);
+		$this->Message($msg);
+		return $this;
+	}
 	
 	/**
 	 * 设置回复音乐
@@ -851,33 +917,59 @@ class Wechat
 	 * 创建菜单
 	 * @param array $data 菜单数组数据
 	 * example:
-		  {
-		     "button":[
-		     {	
-		          "type":"click",
-		          "name":"今日歌曲",
-		          "key":"MENU_KEY_MUSIC"
-		      },
-		      {
-		           "type":"view",
-		           "name":"歌手简介",
-		           "url":"http://www.qq.com/"
-		      },
-		      {
-		           "name":"菜单",
-		           "sub_button":[
-		            {
-		               "type":"click",
-		               "name":"hello word",
-		               "key":"MENU_KEY_MENU"
-		            },
-		            {
-		               "type":"click",
-		               "name":"赞一下我们",
-		               "key":"MENU_KEY_GOOD"
-		            }]
-		       }]
-		 }
+     * 	array (
+     * 	    'button' => array (
+     * 	      0 => array (
+     * 	        'name' => '扫码',
+     * 	        'sub_button' => array (
+     * 	            0 => array (
+     * 	              'type' => 'scancode_waitmsg',
+     * 	              'name' => '扫码带提示',
+     * 	              'key' => 'rselfmenu_0_0',
+     * 	              'sub_button' => ''
+     * 	            ),
+     * 	            1 => array (
+     * 	              'type' => 'scancode_push',
+     * 	              'name' => '扫码推事件',
+     * 	              'key' => 'rselfmenu_0_1',
+     * 	              'sub_button' => ''
+     * 	            ),
+     * 	        ),
+     * 	      ),
+     * 	      1 => array (
+     * 	        'name' => '发图',
+     * 	        'sub_button' => array (
+     * 	            0 => array (
+     * 	              'type' => 'pic_sysphoto',
+     * 	              'name' => '系统拍照发图',
+     * 	              'key' => 'rselfmenu_1_0',
+     * 	              'sub_button' => ''
+     * 	            ),
+     * 	            1 => array (
+     * 	              'type' => 'pic_photo_or_album',
+     * 	              'name' => '拍照或者相册发图',
+     * 	              'key' => 'rselfmenu_1_1',
+     * 	              'sub_button' => ''
+     * 	            )
+     * 	        ),
+     * 	      ),
+     * 	      2 => array (
+     * 	        'type' => 'location_select',
+     * 	        'name' => '发送位置',
+     * 	        'key' => 'rselfmenu_2_0',
+     * 	        'sub_button' => ''
+     * 	      ),
+     * 	    ),
+     * 	)
+     * type可以选择为以下几种,其中5-8除了收到菜单事件以外,还会单独收到对应类型的信息。
+     * 1、click:点击推事件
+     * 2、view:跳转URL
+     * 3、scancode_push:扫码推事件
+     * 4、scancode_waitmsg:扫码推事件且弹出“消息接收中”提示框
+     * 5、pic_sysphoto:弹出系统拍照发图
+     * 6、pic_photo_or_album:弹出拍照或者相册发图
+     * 7、pic_weixin:弹出微信相册发图器
+     * 8、location_select:弹出地理位置选择器
 	 */
 	public function createMenu($data){
 		if (!$this->access_token && !$this->checkAuth()) return false;