Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the error problem of php Wechat login 41001

2025-04-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces the relevant knowledge of "how to solve the php Wechat login 41001 error problem". The editor shows you the operation process through an actual case. The method of operation is simple, fast and practical. I hope this "how to solve the php Wechat login 41001 error problem" article can help you solve the problem.

Php Wechat login 41001 error solution: 1, view the log; 2, remove the backslash through stripslashes; 3, decode through json_decode.

This article operating environment: windows7 system, PHP7.1 version, DELL G3 computer

How to solve the error of php Wechat login 41001?

Mini Program login decrypts user data encryptedData-41001: illegal encodingAesKey

Question:

Do Mini Program Wechat authorization to log in, first get code, then get session_key and open_id, then get encryptedData, send it to the server to decrypt and get user information, but sometimes succeed, sometimes return a-41001 error, observe the log, get session_key, what is the cause of this, and how should it be solved?

Solution:

At the beginning, the direction of consideration has always been the expiration of session_key, because I do not know the expiration of session_key, and then I know that this is not the cause after many tests.

Then began to look through a variety of related blogs and search for related problems, and finally did not find a solution, may be the emergence of this problem is too inappropriate, so there are not many problems in this area

Finally, I started to look at the decrypted SDK source code, and then found that-41001 was because it verified the length of the session_key.

If (strlen ($this- > sessionKey)! = 24) {return ErrorCode::$IllegalAesKey;} / / public static $IllegalAesKey =-41001pacing / >-41001: illegal encodingAesKey

Finally, I took a closer look at the log (there was also a detailed comparison of session_key before, but I just saw the value, a long string of characters, and I didn't understand the meaning of it, and I knew that some of them were successful and some of them failed, and I couldn't find the rules at all). Only by paying attention to the length of session_key could I see the tricks in it.

The json string of PHP is sometimes escaped with a backslash "\". When dealing with PHP, you need to remove the backslash before json_decode.

$str = stripslashes ($json); $arr = json_decode ($str,true)

Using the stripslashes () function, the problem is solved!

This is the end of the content on "how to solve the problem of php Wechat login 41001 error". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report