Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

公众号类库修改解密时订阅号appid问题的解决代码/代码同步修改/注释异常输出代码 #141

Merged
merged 1 commit into from Oct 17, 2014

Conversation

binsee
Copy link
Contributor

@binsee binsee commented Oct 16, 2014

1、公众号类库 修改关于解密时订阅号appid问题的解决代码,避免服务号appid错误而无法检测到,且覆盖掉服务号appid的情况

valid()方法中修改:

                $this->postxml = $array[1];
-               $this->appid = $array[2];//为了没有appid的订阅号。
+               if (!$this->appid)
+                   $this->appid = $array[2];//为了没有appid的订阅号。

decrypt($encrypted, $appid) 方法中修改:

             $from_appid = substr($content, $xml_len + 4);
+            if (!$appid)
+                $appid = $from_appid;
+            //如果传入的appid是空的,则认为是订阅号,使用数据中提取出来的appid
         } catch (Exception $e) {
-            print $e;
+            //print $e;
             return array(ErrorCode::$IllegalBuffer, null);
         }
-        //if ($from_appid != $appid)
-            //return array(ErrorCode::$ValidateAppidError, null);
-        //注释上面两行是为了没有appid的订阅号
-        
+        if ($from_appid != $appid)
+            return array(ErrorCode::$ValidateAppidError, null);
+        //不注释上边两行,避免传入appid是错误的情况
         return array(0, $xml_content, $from_appid); //增加appid,为了解决后面加密回复消息的时候没有appid的订阅号会无法回复

2、公众号类库、企业号类库 注释掉加密库的异常输出代码;调用方法生成随机字符串,而不再使用固定的字符串了

修改内容:

-            $random = "aaaabbbbccccdddd"; //$this->getRandomStr();
+            $random = $this->getRandomStr();//"aaaabbbbccccdddd"; 
         } catch (Exception $e) {
-            print $e;
+            //print $e;
             return array(ErrorCode::$IllegalBuffer, null);
         }
         } catch (Exception $e) {
-            print $e;
+            //print $e;
             return array(ErrorCode::$EncryptAESError, null);
         }

以上为修改的部分

dodgepudding added a commit that referenced this pull request Oct 17, 2014
公众号类库修改解密时订阅号appid问题的解决代码/代码同步修改/注释异常输出代码
@dodgepudding dodgepudding merged commit 05466f5 into dodgepudding:master Oct 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants