This is a creation in Article, where the information may have evolved or changed.
The development of public platforms, in the end, is worthless, because the purpose of the public platform is to give people, there is no technical threshold, but the process is too much, recorded, hoping to help other people.
Find the Entrance
In the basic configuration menu, you can see the Modify Configuration button (which is really not found in the group).
Fill in the Parameters
If the server has already mapped the address to port 80 via nginx, it can be written like this (token and key have been replaced, of course).
Start rubbing code
In the document, the official wrote: The 3 parameters sorted in dictionary order, at first I was crazy, and later found that the language version of the sort ... Let's get to the next.
We add a route, this address is the URL that fills in the server configuration
Then add the Wxconnect.go file in the controllers
PackageControllersImport("Github.com/astaxie/beego" "Strings" "Sort" "CRYPTO/SHA1" "IO" "FMT")typeWxconnectcontrollerstruct{Beego. Controller}ConstToken ="Dswq1322s1dfsf31s2af321231rew"func(c *wxconnectcontroller) Get () {//Access Verification This is the first time the server will send a request after filling in the URL. //c.ctx.request.url-------------wx_connect?signature=038d75ed5485b9881a01b3b93e85f9fff28ea739&echostr= 5756456183388806654×tamp=1476173150&nonce=1093541731 //Developer submits information (including URL, Token), the server sends an HTTP GET request to the completed URL, //get request carries four parameters: signature, timestamp, nonce and echostr. The public service program should be authenticated as requiredTimestamp, Nonce,signaturein: = C.getstring ("Timestamp"), C.getstring ("Nonce"), C.getstring ("Signature") Signaturegen: = Makesignature (timestamp, nonce)//The string obtained after encryption is compared with signature, if consistent, indicating that the request originated from ifSignaturegen! = Signaturein {fmt. Printf ("Signaturegen! = Signaturein signaturegen=%s,signaturein=%s\n", Signaturegen, Signaturein) c.ctx.writestring ("") }Else{//If the request is from, returns the contents of the ECHOSTR parameter as it is completed, the access verification takes effect and the developer configuration submission succeeds. ECHOSTR: = c.getstring ("Echostr") c.ctx.writestring (ECHOSTR)}}funcMakesignature (timestamp, noncestring)string{//1. Dictionary ordering of the three parameters of Plat_token, timestamp and nonceSL: = []string{Token, timestamp, nonce} sort. Strings (SL)//2. Concatenation of three parameter strings into a single string for SHA1 encryptionS: = SHA1. New () Io. WriteString (S, strings. Join (SL,""))returnFmt. Sprintf ("%x", S.sum (Nil))}
Re-run the project, click on the Settings page of the Submit button, should be able to display through, please carefully proofread parameters, copy and paste good.
At this point, the public platform has opened the door to you (remember to click the Enable button, otherwise the light verification through no eggs).