Browse Source

This fixes #83 之前的有疏忽

之前有疏忽,之前微信是返回errmsg给token的,现在变成了redirect_url
Albert Lee 11 years ago
parent
commit
8fb5c84619
1 changed files with 10 additions and 2 deletions
  1. 10 2
      wechatext.class.php

+ 10 - 2
wechatext.class.php

@@ -618,14 +618,22 @@ class Wechatext
 		$cookie = '';
 		$this->log($snoopy->results);
 		$result = json_decode($snoopy->results,true);
-		if ($result['ErrCode']!=0) return false;
+		
+		if (!isset($result['base_resp'])) {
+			return false;
+		}
+
+		if ($result['base_resp']['ret'] != 0) {
+			return false;
+		}
+        
 		foreach ($snoopy->headers as $key => $value) {
 			$value = trim($value);
 			if(preg_match('/^set-cookie:[\s]+([^=]+)=([^;]+)/i', $value,$match))
 				$cookie .=$match[1].'='.$match[2].'; ';
 		}
 		
-		preg_match("/token=(\d+)/i",$result['ErrMsg'],$matches);
+		preg_match("/token=(\d+)/i",$result['redirect_url'],$matches);
 		if($matches){
 			$this->_token = $matches[1];
 			$this->log('token:'.$this->_token);