Browse Source

Merge pull request #126 from binsee/master

增加新出的自定义菜单推送事件方法,及其他小更新
dodge 10 years ago
parent
commit
71015d2e05
7 changed files with 456 additions and 63 deletions
  1. 3 1
      .gitignore
  2. 16 1
      README.md
  3. 199 54
      Thinkphp/Wechat.class.php
  4. 3 2
      Thinkphp/Wechatext.class.php
  5. 110 0
      errCode.php
  6. 124 5
      wechat.class.php
  7. 1 0
      wechat.js

+ 3 - 1
.gitignore

@@ -1 +1,3 @@
-/nbproject/private/
+/nbproject/private/
+.buildpath
+/wiki/

+ 16 - 1
README.md

@@ -157,7 +157,22 @@ https://mp.weixin.qq.com/cgi-bin/readtemplate?t=business/course2_tmpl&lang=zh_CN
 	   callback:function(){}
 	   callback:function(){}
 	};
 	};
  ```
  ```
- 
+ 5. errCode.php 
+当调用API接口失败时,可以用此类来换取失败原因的中文说明。
+
+使用方法:
+```php
+include "errCode.php";
+
+$ret=ErrCode::getErrText(48001);
+
+if ($ret) 
+	echo $ret;
+else 
+    echo "未找到对应的内容";
+
+```
+
 
 
 官方Wechat调用示例:
 官方Wechat调用示例:
 --------  
 --------  

+ 199 - 54
Thinkphp/Wechat.class.php

@@ -359,12 +359,130 @@ class Wechat
 		if (isset($this->_receive['EventKey'])){
 		if (isset($this->_receive['EventKey'])){
 			$array['key'] = $this->_receive['EventKey'];
 			$array['key'] = $this->_receive['EventKey'];
 		}
 		}
-		
 		if (isset($array) && count($array) > 0) {
 		if (isset($array) && count($array) > 0) {
 			return $array;
 			return $array;
 		} else {
 		} else {
 			return false;
 			return false;
-		} 
+		}
+	}
+	
+	/**
+	 * 获取自定义菜单的扫码推事件信息
+	 * 
+	 * 事件类型为以下两种时则调用此方法有效
+	 * Event	 事件类型,scancode_push
+	 * Event	 事件类型,scancode_waitmsg
+	 * 
+	 * @return: array | false
+	 * array (
+	 *     'ScanType'=>'qrcode',
+	 *     'ScanResult'=>'123123'
+	 * )
+	 */
+	public function getRevScanInfo(){
+		if (isset($this->_receive['ScanCodeInfo'])){
+		    if (!is_array($this->_receive['SendPicsInfo'])) {
+		        $array=(array)$this->_receive['ScanCodeInfo'];
+		        $this->_receive['ScanCodeInfo']=$array;
+		    }else {
+		        $array=$this->_receive['ScanCodeInfo'];
+		    }
+		}
+		if (isset($array) && count($array) > 0) {
+			return $array;
+		} else {
+			return false;
+		}
+	}
+	
+	/**
+	 * 获取自定义菜单的图片发送事件信息
+	 * 
+	 * 事件类型为以下三种时则调用此方法有效
+	 * Event	 事件类型,pic_sysphoto        弹出系统拍照发图的事件推送
+	 * Event	 事件类型,pic_photo_or_album  弹出拍照或者相册发图的事件推送
+	 * Event	 事件类型,pic_weixin          弹出微信相册发图器的事件推送
+	 * 
+	 * @return: array | false
+	 * array (
+	 *   'Count' => '2',
+	 *   'PicList' => 
+	 *   array (
+	 *     'item' => 
+	 *     array (
+	 *       0 => 
+	 *       array (
+	 *         'PicMd5Sum' => 'aaae42617cf2a14342d96005af53624c',
+	 *       ),
+	 *       1 => 
+	 *       array (
+	 *         'PicMd5Sum' => '149bd39e296860a2adc2f1bb81616ff8',
+	 *       ),
+	 *     ),
+	 *   ),
+	 * )
+	 * 
+	 */
+	public function getRevSendPicsInfo(){
+		if (isset($this->_receive['SendPicsInfo'])){
+		    if (!is_array($this->_receive['SendPicsInfo'])) {
+		        $array=(array)$this->_receive['SendPicsInfo'];
+		        if (isset($array['PicList'])){
+		            $array['PicList']=(array)$array['PicList'];
+		            $item=$array['PicList']['item'];
+		            $array['PicList']['item']=array();
+		            foreach ( $item as $key => $value ){
+		                $array['PicList']['item'][$key]=(array)$value;
+		            }
+		        }
+		        $this->_receive['SendPicsInfo']=$array;
+		    } else {
+		        $array=$this->_receive['SendPicsInfo'];
+		    }
+		}
+		if (isset($array) && count($array) > 0) {
+			return $array;
+		} else {
+			return false;
+		}
+	}
+
+	/**
+	 * 获取自定义菜单的地理位置选择器事件推送
+	 *
+	 * 事件类型为以下时则可以调用此方法有效
+	 * Event	 事件类型,location_select        弹出系统拍照发图的事件推送
+	 *
+	 * @return: array | false
+	 * array (
+	 *   'Location_X' => '33.731655000061',
+	 *   'Location_Y' => '113.29955200008047',
+	 *   'Scale' => '16',
+	 *   'Label' => '某某市某某区某某路',
+	 *   'Poiname' => '',
+	 * )
+	 * 
+	 */
+	public function getRevSendGeoInfo(){
+	    if (isset($this->_receive['SendLocationInfo'])){
+	        if (!is_array($this->_receive['SendLocationInfo'])) {
+	            $array=(array)$this->_receive['SendLocationInfo'];
+	            if (empty($array['Poiname'])) {
+	                $array['Poiname']="";
+	            }
+	            if (empty($array['Label'])) {
+	                $array['Label']="";
+	            }
+	            $this->_receive['SendLocationInfo']=$array;
+	        } else {
+	            $array=$this->_receive['SendLocationInfo'];
+	        }
+	    }
+	    if (isset($array) && count($array) > 0) {
+	        return $array;
+	    } else {
+	        return false;
+	    }
 	}
 	}
 	
 	
 	/**
 	/**
@@ -960,7 +1078,7 @@ class Wechat
 	 * @param int $scene_id 自定义追踪id
 	 * @param int $scene_id 自定义追踪id
 	 * @param int $type 0:临时二维码;1:永久二维码(此时expire参数无效)
 	 * @param int $type 0:临时二维码;1:永久二维码(此时expire参数无效)
 	 * @param int $expire 临时二维码有效期,最大为1800秒
 	 * @param int $expire 临时二维码有效期,最大为1800秒
-	 * @return array('ticket'=>'qrcode字串','expire_seconds'=>1800)
+	 * @return array('ticket'=>'qrcode字串','expire_seconds'=>1800,'url'=>'二维码图片解析后的地址')
 	 */
 	 */
 	public function getQRCode($scene_id,$type=0,$expire=1800){
 	public function getQRCode($scene_id,$type=0,$expire=1800){
 		if (!$this->access_token && !$this->checkAuth()) return false;
 		if (!$this->access_token && !$this->checkAuth()) return false;
@@ -1001,25 +1119,25 @@ class Wechat
 	 * @return boolean|string url 成功则返回转换后的短url
 	 * @return boolean|string url 成功则返回转换后的短url
 	 */
 	 */
 	public function getShortUrl($long_url){
 	public function getShortUrl($long_url){
-		if (!$this->access_token && !$this->checkAuth()) return false;
-		$data = array(
-				'action'=>'long2short',
-				'long_url'=>$long_url
-		);
-		$result = $this->http_post(self::API_URL_PREFIX.self::SHORT_URL.'access_token='.$this->access_token,self::json_encode($data));
-		if ($result)
-		{
-			$json = json_decode($result,true);
-			if (!$json || !empty($json['errcode'])) {
-				$this->errCode = $json['errcode'];
-				$this->errMsg = $json['errmsg'];
-				return false;
-			}
-			return $json['short_url'];
-		}
-		return false;
+	    if (!$this->access_token && !$this->checkAuth()) return false;
+	    $data = array(
+            'action'=>'long2short',
+            'long_url'=>$long_url
+	    );
+	    $result = $this->http_post(self::API_URL_PREFIX.self::SHORT_URL.'access_token='.$this->access_token,self::json_encode($data));
+	    if ($result)
+	    {
+	        $json = json_decode($result,true);
+	        if (!$json || !empty($json['errcode'])) {
+	            $this->errCode = $json['errcode'];
+	            $this->errMsg = $json['errmsg'];
+	            return false;
+	        }
+	        return $json['short_url'];
+	    }
+	    return false;
 	}
 	}
-	
+
 	/**
 	/**
 	 * 批量获取关注用户列表
 	 * 批量获取关注用户列表
 	 * @param unknown $next_openid
 	 * @param unknown $next_openid
@@ -1043,7 +1161,8 @@ class Wechat
 	/**
 	/**
 	 * 获取关注者详细信息
 	 * 获取关注者详细信息
 	 * @param string $openid
 	 * @param string $openid
-	 * @return array
+	 * @return array {subscribe,openid,nickname,sex,city,province,country,language,headimgurl,subscribe_time,[unionid]}
+	 * 注意:unionid字段 只有在用户将公众号绑定到微信开放平台账号后,才会出现。建议调用前用isset()检测一下
 	 */
 	 */
 	public function getUserInfo($openid){
 	public function getUserInfo($openid){
 		if (!$this->access_token && !$this->checkAuth()) return false;
 		if (!$this->access_token && !$this->checkAuth()) return false;
@@ -1113,24 +1232,24 @@ class Wechat
 	 * @return boolean|int 成功则返回用户分组id
 	 * @return boolean|int 成功则返回用户分组id
 	 */
 	 */
 	public function getUserGroup($openid){
 	public function getUserGroup($openid){
-		if (!$this->access_token && !$this->checkAuth()) return false;
-		$data = array(
-				'openid'=>$openid
-		);
-		$result = $this->http_post(self::API_URL_PREFIX.self::USER_GROUP_URL.'access_token='.$this->access_token,self::json_encode($data));
-		if ($result)
-		{
-			$json = json_decode($result,true);
-			if (!$json || !empty($json['errcode'])) {
-				$this->errCode = $json['errcode'];
-				$this->errMsg = $json['errmsg'];
-				return false;
-			} else
-				if (isset($json['groupid'])) return $json['groupid'];
-		}
-		return false;
+	    if (!$this->access_token && !$this->checkAuth()) return false;
+	    $data = array(
+	            'openid'=>$openid
+	    );
+	    $result = $this->http_post(self::API_URL_PREFIX.self::USER_GROUP_URL.'access_token='.$this->access_token,self::json_encode($data));
+	    if ($result)
+	    {
+	        $json = json_decode($result,true);
+	        if (!$json || !empty($json['errcode'])) {
+	            $this->errCode = $json['errcode'];
+	            $this->errMsg = $json['errmsg'];
+	            return false;
+	        } else 
+                if (isset($json['groupid'])) return $json['groupid'];
+	    }
+	    return false;
 	}
 	}
-	
+    
 	/**
 	/**
 	 * 新增自定分组
 	 * 新增自定分组
 	 * @param string $name 分组名称
 	 * @param string $name 分组名称
@@ -1283,7 +1402,8 @@ class Wechat
 	 * 获取授权后的用户资料
 	 * 获取授权后的用户资料
 	 * @param string $access_token
 	 * @param string $access_token
 	 * @param string $openid
 	 * @param string $openid
-	 * @return array {openid,nickname,sex,province,city,country,headimgurl,privilege}
+	 * @return array {openid,nickname,sex,province,city,country,headimgurl,privilege,[unionid]}
+	 * 注意:unionid字段 只有在用户将公众号绑定到微信开放平台账号后,才会出现。建议调用前用isset()检测一下
 	 */
 	 */
 	public function getOauthUserinfo($access_token,$openid){
 	public function getOauthUserinfo($access_token,$openid){
 		$result = $this->http_get(self::OAUTH_USERINFO_URL.'access_token='.$access_token.'&openid='.$openid);
 		$result = $this->http_get(self::OAUTH_USERINFO_URL.'access_token='.$access_token.'&openid='.$openid);
@@ -1299,7 +1419,7 @@ class Wechat
 		}
 		}
 		return false;
 		return false;
 	}
 	}
-	
+
 	/**
 	/**
 	 * 检验授权凭证是否有效
 	 * 检验授权凭证是否有效
 	 * @param string $access_token
 	 * @param string $access_token
@@ -1307,18 +1427,18 @@ class Wechat
 	 * @return boolean 是否有效
 	 * @return boolean 是否有效
 	 */
 	 */
 	public function getOauthAuth($access_token,$openid){
 	public function getOauthAuth($access_token,$openid){
-		$result = $this->http_get(self::OAUTH_AUTH_URL.'access_token='.$access_token.'&openid='.$openid);
-		if ($result)
-		{
-			$json = json_decode($result,true);
-			if (!$json || !empty($json['errcode'])) {
-				$this->errCode = $json['errcode'];
-				$this->errMsg = $json['errmsg'];
-				return false;
-			} else
-				if ($json['errcode']==0) return true;
-		}
-		return false;
+	    $result = $this->http_get(self::OAUTH_AUTH_URL.'access_token='.$access_token.'&openid='.$openid);
+	    if ($result)
+	    {
+	        $json = json_decode($result,true);
+	        if (!$json || !empty($json['errcode'])) {
+	            $this->errCode = $json['errcode'];
+	            $this->errMsg = $json['errmsg'];
+	            return false;
+	        } else
+	          if ($json['errcode']==0) return true;
+	    }
+	    return false;
 	}
 	}
 	
 	
 	/**
 	/**
@@ -1359,6 +1479,32 @@ class Wechat
 	}
 	}
 	
 	
 	/**
 	/**
+	 * 生成原生支付url
+	 * @param number $productid 商品编号,最长为32字节
+	 * @return string
+	 */
+	public function createNativeUrl($productid){
+		    $nativeObj["appid"] = $this->appid;
+		    $nativeObj["appkey"] = $this->paysignkey;
+		    $nativeObj["productid"] = urlencode($productid);
+		    $nativeObj["timestamp"] = time();
+		    $nativeObj["noncestr"] = $this->generateNonceStr();
+		    $nativeObj["sign"] = $this->getSignature($nativeObj);
+		    unset($nativeObj["appkey"]);
+		    $bizString = "";
+		    foreach($nativeObj as $key => $value)
+		    {
+			if(strlen($bizString) == 0)
+				$bizString .= $key . "=" . $value;
+			else
+				$bizString .= "&" . $key . "=" . $value;
+		    }
+		    return "weixin://wxpay/bizpayurl?".$bizString;
+		    //weixin://wxpay/bizpayurl?sign=XXXXX&appid=XXXXXX&productid=XXXXXX&timestamp=XXXXXX&noncestr=XXXXXX
+	}
+
+	
+	/**
 	 * 生成订单package字符串
 	 * 生成订单package字符串
 	 * @param string $out_trade_no 必填,商户系统内部的订单号,32个字符内,确保在商户系统唯一
 	 * @param string $out_trade_no 必填,商户系统内部的订单号,32个字符内,确保在商户系统唯一
 	 * @param string $body 必填,商品描述,128 字节以下
 	 * @param string $body 必填,商品描述,128 字节以下
@@ -1558,7 +1704,6 @@ class Wechat
 	public function sendTemplateMessage($data){
 	public function sendTemplateMessage($data){
 		if (!$this->access_token && !$this->checkAuth()) return false;
 		if (!$this->access_token && !$this->checkAuth()) return false;
 		$result = $this->http_post(self::API_URL_PREFIX.self::TEMPLATE_SEND_URL.'access_token='.$this->access_token,self::json_encode($data));
 		$result = $this->http_post(self::API_URL_PREFIX.self::TEMPLATE_SEND_URL.'access_token='.$this->access_token,self::json_encode($data));
-		
 		if($result){
 		if($result){
 			$json = json_decode($result,true);
 			$json = json_decode($result,true);
 			if (!$json || !empty($json['errcode'])) {
 			if (!$json || !empty($json['errcode'])) {

+ 3 - 2
Thinkphp/Wechatext.class.php

@@ -629,7 +629,8 @@ class Wechatext
 			$this->_token = $matches[1];
 			$this->_token = $matches[1];
 			$this->log('token:'.$this->_token);
 			$this->log('token:'.$this->_token);
 		}
 		}
-		$this->saveCookie($this->_cookiename,$cookie);
+		$cookies='{"cookie":"'.$cookie.'","token":"'.$this->_token.'"}';
+		$this->saveCookie($this->_cookiename,$cookies);
 		return $cookie;
 		return $cookie;
 	}
 	}
 
 
@@ -652,7 +653,7 @@ class Wechatext
 		$data = S($filename);
 		$data = S($filename);
 		if($data){
 		if($data){
 			$login=json_decode($data,true);
 			$login=json_decode($data,true);
-			$send_snoopy = new Snoopy; 
+			$send_snoopy = new Snoopy;
 			$send_snoopy->rawheaders['Cookie']= $login['cookie'];
 			$send_snoopy->rawheaders['Cookie']= $login['cookie'];
 			$send_snoopy->maxredirs = 0;
 			$send_snoopy->maxredirs = 0;
 			$url = "https://mp.weixin.qq.com/cgi-bin/home?t=home/index&lang=zh_CN&token=".$login['token'];
 			$url = "https://mp.weixin.qq.com/cgi-bin/home?t=home/index&lang=zh_CN&token=".$login['token'];

+ 110 - 0
errCode.php

@@ -0,0 +1,110 @@
+<?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'=>'不合法的OpenID',
+	    '40004'=>'不合法的媒体文件类型',
+	    '40005'=>'不合法的文件类型',
+	    '40006'=>'不合法的文件大小',
+	    '40007'=>'不合法的媒体文件id',
+	    '40008'=>'不合法的消息类型',
+	    '40009'=>'不合法的图片文件大小',
+	    '40010'=>'不合法的语音文件大小',
+	    '40011'=>'不合法的视频文件大小',
+	    '40012'=>'不合法的缩略图文件大小',
+	    '40013'=>'不合法的APPID',
+	    '40014'=>'不合法的access_token',
+	    '40015'=>'不合法的菜单类型',
+	    '40016'=>'不合法的按钮个数',
+	    '40017'=>'不合法的按钮个数',
+	    '40018'=>'不合法的按钮名字长度',
+	    '40019'=>'不合法的按钮KEY长度',
+	    '40020'=>'不合法的按钮URL长度',
+	    '40021'=>'不合法的菜单版本号',
+	    '40022'=>'不合法的子菜单级数',
+	    '40023'=>'不合法的子菜单按钮个数',
+	    '40024'=>'不合法的子菜单按钮类型',
+	    '40025'=>'不合法的子菜单按钮名字长度',
+	    '40026'=>'不合法的子菜单按钮KEY长度',
+	    '40027'=>'不合法的子菜单按钮URL长度',
+	    '40028'=>'不合法的自定义菜单使用用户',
+	    '40029'=>'不合法的oauth_code',
+	    '40030'=>'不合法的refresh_token',
+	    '40031'=>'不合法的openid列表',
+	    '40032'=>'不合法的openid列表长度',
+	    '40033'=>'不合法的请求字符,不能包含\uxxxx格式的字符',
+	    '40035'=>'不合法的参数',
+	    '40038'=>'不合法的请求格式',
+	    '40039'=>'不合法的URL长度',
+	    '40050'=>'不合法的分组id',
+	    '40051'=>'分组名字不合法',
+	    '41001'=>'缺少access_token参数',
+	    '41002'=>'缺少appid参数',
+	    '41003'=>'缺少refresh_token参数',
+	    '41004'=>'缺少secret参数',
+	    '41005'=>'缺少多媒体文件数据',
+	    '41006'=>'缺少media_id参数',
+	    '41007'=>'缺少子菜单数据',
+	    '41008'=>'缺少oauth code',
+	    '41009'=>'缺少openid',
+	    '42001'=>'access_token超时',
+	    '42002'=>'refresh_token超时',
+	    '42003'=>'oauth_code超时',
+	    '43001'=>'需要GET请求',
+	    '43002'=>'需要POST请求',
+	    '43003'=>'需要HTTPS请求',
+	    '43004'=>'需要接收者关注',
+	    '43005'=>'需要好友关系',
+	    '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内容错误',
+	    '48001'=>'api功能未授权',
+	    '50001'=>'用户未授权该api',
+	);
+	
+	public static function getErrText($err) {
+		if (isset(self::$errCode[$err])) {
+			return self::$errCode[$err];
+		}else {
+		    return false;
+		};
+	}
+}
+
+?>

+ 124 - 5
wechat.class.php

@@ -354,12 +354,130 @@ class Wechat
 		if (isset($this->_receive['EventKey'])){
 		if (isset($this->_receive['EventKey'])){
 			$array['key'] = $this->_receive['EventKey'];
 			$array['key'] = $this->_receive['EventKey'];
 		}
 		}
-		
 		if (isset($array) && count($array) > 0) {
 		if (isset($array) && count($array) > 0) {
 			return $array;
 			return $array;
 		} else {
 		} else {
 			return false;
 			return false;
-		} 
+		}
+	}
+	
+	/**
+	 * 获取自定义菜单的扫码推事件信息
+	 * 
+	 * 事件类型为以下两种时则调用此方法有效
+	 * Event	 事件类型,scancode_push
+	 * Event	 事件类型,scancode_waitmsg
+	 * 
+	 * @return: array | false
+	 * array (
+	 *     'ScanType'=>'qrcode',
+	 *     'ScanResult'=>'123123'
+	 * )
+	 */
+	public function getRevScanInfo(){
+		if (isset($this->_receive['ScanCodeInfo'])){
+		    if (!is_array($this->_receive['SendPicsInfo'])) {
+		        $array=(array)$this->_receive['ScanCodeInfo'];
+		        $this->_receive['ScanCodeInfo']=$array;
+		    }else {
+		        $array=$this->_receive['ScanCodeInfo'];
+		    }
+		}
+		if (isset($array) && count($array) > 0) {
+			return $array;
+		} else {
+			return false;
+		}
+	}
+	
+	/**
+	 * 获取自定义菜单的图片发送事件信息
+	 * 
+	 * 事件类型为以下三种时则调用此方法有效
+	 * Event	 事件类型,pic_sysphoto        弹出系统拍照发图的事件推送
+	 * Event	 事件类型,pic_photo_or_album  弹出拍照或者相册发图的事件推送
+	 * Event	 事件类型,pic_weixin          弹出微信相册发图器的事件推送
+	 * 
+	 * @return: array | false
+	 * array (
+	 *   'Count' => '2',
+	 *   'PicList' => 
+	 *   array (
+	 *     'item' => 
+	 *     array (
+	 *       0 => 
+	 *       array (
+	 *         'PicMd5Sum' => 'aaae42617cf2a14342d96005af53624c',
+	 *       ),
+	 *       1 => 
+	 *       array (
+	 *         'PicMd5Sum' => '149bd39e296860a2adc2f1bb81616ff8',
+	 *       ),
+	 *     ),
+	 *   ),
+	 * )
+	 * 
+	 */
+	public function getRevSendPicsInfo(){
+		if (isset($this->_receive['SendPicsInfo'])){
+		    if (!is_array($this->_receive['SendPicsInfo'])) {
+		        $array=(array)$this->_receive['SendPicsInfo'];
+		        if (isset($array['PicList'])){
+		            $array['PicList']=(array)$array['PicList'];
+		            $item=$array['PicList']['item'];
+		            $array['PicList']['item']=array();
+		            foreach ( $item as $key => $value ){
+		                $array['PicList']['item'][$key]=(array)$value;
+		            }
+		        }
+		        $this->_receive['SendPicsInfo']=$array;
+		    } else {
+		        $array=$this->_receive['SendPicsInfo'];
+		    }
+		}
+		if (isset($array) && count($array) > 0) {
+			return $array;
+		} else {
+			return false;
+		}
+	}
+
+	/**
+	 * 获取自定义菜单的地理位置选择器事件推送
+	 *
+	 * 事件类型为以下时则可以调用此方法有效
+	 * Event	 事件类型,location_select        弹出系统拍照发图的事件推送
+	 *
+	 * @return: array | false
+	 * array (
+	 *   'Location_X' => '33.731655000061',
+	 *   'Location_Y' => '113.29955200008047',
+	 *   'Scale' => '16',
+	 *   'Label' => '某某市某某区某某路',
+	 *   'Poiname' => '',
+	 * )
+	 * 
+	 */
+	public function getRevSendGeoInfo(){
+	    if (isset($this->_receive['SendLocationInfo'])){
+	        if (!is_array($this->_receive['SendLocationInfo'])) {
+	            $array=(array)$this->_receive['SendLocationInfo'];
+	            if (empty($array['Poiname'])) {
+	                $array['Poiname']="";
+	            }
+	            if (empty($array['Label'])) {
+	                $array['Label']="";
+	            }
+	            $this->_receive['SendLocationInfo']=$array;
+	        } else {
+	            $array=$this->_receive['SendLocationInfo'];
+	        }
+	    }
+	    if (isset($array) && count($array) > 0) {
+	        return $array;
+	    } else {
+	        return false;
+	    }
 	}
 	}
 	
 	
 	/**
 	/**
@@ -1033,7 +1151,8 @@ class Wechat
 	/**
 	/**
 	 * 获取关注者详细信息
 	 * 获取关注者详细信息
 	 * @param string $openid
 	 * @param string $openid
-	 * @return array
+	 * @return array {subscribe,openid,nickname,sex,city,province,country,language,headimgurl,subscribe_time,[unionid]}
+	 * 注意:unionid字段 只有在用户将公众号绑定到微信开放平台账号后,才会出现。建议调用前用isset()检测一下
 	 */
 	 */
 	public function getUserInfo($openid){
 	public function getUserInfo($openid){
 		if (!$this->access_token && !$this->checkAuth()) return false;
 		if (!$this->access_token && !$this->checkAuth()) return false;
@@ -1273,7 +1392,8 @@ class Wechat
 	 * 获取授权后的用户资料
 	 * 获取授权后的用户资料
 	 * @param string $access_token
 	 * @param string $access_token
 	 * @param string $openid
 	 * @param string $openid
-	 * @return array {openid,nickname,sex,province,city,country,headimgurl,privilege}
+	 * @return array {openid,nickname,sex,province,city,country,headimgurl,privilege,[unionid]}
+	 * 注意:unionid字段 只有在用户将公众号绑定到微信开放平台账号后,才会出现。建议调用前用isset()检测一下
 	 */
 	 */
 	public function getOauthUserinfo($access_token,$openid){
 	public function getOauthUserinfo($access_token,$openid){
 		$result = $this->http_get(self::OAUTH_USERINFO_URL.'access_token='.$access_token.'&openid='.$openid);
 		$result = $this->http_get(self::OAUTH_USERINFO_URL.'access_token='.$access_token.'&openid='.$openid);
@@ -1574,7 +1694,6 @@ class Wechat
 	public function sendTemplateMessage($data){
 	public function sendTemplateMessage($data){
 		if (!$this->access_token && !$this->checkAuth()) return false;
 		if (!$this->access_token && !$this->checkAuth()) return false;
 		$result = $this->http_post(self::API_URL_PREFIX.self::TEMPLATE_SEND_URL.'access_token='.$this->access_token,self::json_encode($data));
 		$result = $this->http_post(self::API_URL_PREFIX.self::TEMPLATE_SEND_URL.'access_token='.$this->access_token,self::json_encode($data));
-		
 		if($result){
 		if($result){
 			$json = json_decode($result,true);
 			$json = json_decode($result,true);
 			if (!$json || !empty($json['errcode'])) {
 			if (!$json || !empty($json['errcode'])) {

+ 1 - 0
wechat.js

@@ -192,6 +192,7 @@ WeixinJS.imagePreview = function(urls,current) {
 		});
 		});
 };
 };
 
 
+//微信JsApi支付接口
 WeixinJS.payCallback = function(appId,package,timeStamp,nonceStr,signType,paySign,callback){
 WeixinJS.payCallback = function(appId,package,timeStamp,nonceStr,signType,paySign,callback){
 	if (typeof WeixinJSBridge!='undefined')
 	if (typeof WeixinJSBridge!='undefined')
 	WeixinJSBridge.invoke('getBrandWCPayRequest',{
 	WeixinJSBridge.invoke('getBrandWCPayRequest',{