»WordPress»WordPress real wechat public account verification code viewing plug-in
When you see the title, many people will say that this function has been available for a long time. Why send this article?Yunluo certainly won't take the previous function to write. Today's writing is not a real public number verification code viewing function, which is a function that comes to mind when I sleep in bed.
First of all, let's briefly talk about the design idea. The public number verification code is visible. First, we should design a verification code. The verification code must be unique and has an expiration date. From this point, the visible function of these public number verification codes circulated on the Internet is actually fake, because the verification code is set manually and is a fixed character,You'll know after you use it once.
The first method I think of is to use a public captcha pool, that is, generate some captcha at one time, put them in a TXT file, and then call them randomly. After reading the file, they form an array, and then call out the captcha from the array. After this method is implemented, after thinking about it, I find that although it can achieve the functions I need, it can't be used,After all, this is equivalent to the direct disclosure of captcha, so this method was eliminated and another captcha method was redesigned.
The redesigned captcha scheme is based on time, domain name and wechat token. In terms of time, the unit is 1 hour. There are 60 verification codes per minute. For example, 13-12 is 12. The verification code can be simply set to 12. If you need to change the verification code every 2 minutes, divide the current number of minutes by 2, and so on.Concatenate the website domain name with the current minute string, such as 12https://gitcafe.netIn addition, the wechat public number token is spliced into [12https://gitcafe.netweixintoken】Later, we will encrypt it and use the SHA1 method to calculate a 40 bit string. We will intercept 6 bits of it as the verification code, and then add the date. For example, today is 2-18,Then we will intercept 6 as a string from the 18th to ensure that the verification code does not repeat in 30 days of a month. Finally, this 6-bit string can be sent to wechat public account as a verification code and used to verify whether the verification code entered on the web page is correct.
The verification code design is OK. The following is the connection to the wechat public account. Based on the public account example code, it is slightly changed, only the wechat class is reserved, and other codes are not required. Try it out, OK, no problem.
Wechat is ready, and then WordPress. Here, I'm going to talk about the code visible in the wechat public account verification code, which is popular on the Internet. So many times, it is a native form submission, and it will be repeatedly submitted after refreshing.Cloud down here a little change, change to Ajax to submit the actual experience will be better.
The code in this paper is not important. What's important is the design idea of captcha, which can also be designed where captcha is needed. In addition, this captcha has a small drawback: the expiration time is not calculated from the generation of captcha, but the captcha will expire with time. Therefore, if you get the captcha in 59 seconds, it will be invalid immediately,Of course, this is only a small drawback, do not hinder the use of expired verification code can be re applied.
Plug in description
Because it is a very simple plug-in, there is no background. There are two constants in the plug-in. One is wechat token, and the other is the QR code image of public number. The plug-in can be understood by opening a file. In addition, JS code uses jQuery The other is that the administrator has no effect. If the administrator needs to view it, he needs to exit the account
Plug in download
The content of this paragraph has been hidden. You need to scan the code, follow the wechat public account, apply for the verification code, and send the verification code to get the verification code. The verification code is valid for 2 minutes
Published byClouds fall
No toss, no life, I am a rookie WordPress, a seller playing Taobao, welcome to know me, I am Yunluo!View all posts by cloud