Browse Source

fix wechatext login bugs and edit README

dodgepudding 11 years ago
parent
commit
2c599ca88b
3 changed files with 12 additions and 9 deletions
  1. 4 1
      README.md
  2. 6 2
      Thinkphp/Wechatext.class.php
  3. 2 6
      wechatext.class.php

+ 4 - 1
README.md

@@ -7,7 +7,10 @@ weixin developer SDK.
 使用详解
 -------
 使用前需先打开微信帐号的开发模式,详细步骤请查看微信公众平台接口使用说明:  
-http://mp.weixin.qq.com/wiki/index.php?title=%E6%8E%A5%E5%85%A5%E6%8C%87%E5%8D%97
+http://mp.weixin.qq.com/wiki/
+
+微信支付接入文档:
+https://mp.weixin.qq.com/cgi-bin/readtemplate?t=business/course2_tmpl&lang=zh_CN
 
 1. wechat.class.php  
 调用官方API,具有更灵活的消息分类响应方式,支持链式调用操作 ; 

+ 6 - 2
Thinkphp/Wechatext.class.php

@@ -602,7 +602,7 @@ class Wechatext
 	 */
 	public function login(){
 		$snoopy = new Snoopy; 
-		$submit = "http://mp.weixin.qq.com/cgi-bin/login?lang=zh_CN";
+		$submit = "https://mp.weixin.qq.com/cgi-bin/login?lang=zh_CN";
 		$post["username"] = $this->_account;
 		$post["pwd"] = md5($this->_password);
 		$post["f"] = "json";
@@ -612,7 +612,11 @@ class Wechatext
 		$cookie = '';
 		$this->log($snoopy->results);
 		$result = json_decode($snoopy->results,true);
-		if ($result['base_resp']['err_msg']!='ok') return false;
+		
+		if (!isset($result['base_resp']) || $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))

+ 2 - 6
wechatext.class.php

@@ -608,7 +608,7 @@ class Wechatext
 	 */
 	public function login(){
 		$snoopy = new Snoopy; 
-		$submit = "http://mp.weixin.qq.com/cgi-bin/login?lang=zh_CN";
+		$submit = "https://mp.weixin.qq.com/cgi-bin/login?lang=zh_CN";
 		$post["username"] = $this->_account;
 		$post["pwd"] = md5($this->_password);
 		$post["f"] = "json";
@@ -619,11 +619,7 @@ class Wechatext
 		$this->log($snoopy->results);
 		$result = json_decode($snoopy->results,true);
 		
-		if (!isset($result['base_resp'])) {
-			return false;
-		}
-
-		if ($result['base_resp']['ret'] != 0) {
+		if (!isset($result['base_resp']) || $result['base_resp']['ret'] != 0) {
 			return false;
 		}