After learning nodejs, Xiaobai wanted to use nodejs to develop WeChat and searched many tutorials on the Internet. Now I can only access WeChat (there are many tutorials to access). After accessing WeChat, I should have developed it. However, I am in Kubility (there are few tutorials and no suitable ones can be found), so I have no choice but to ask for help.
I hope you can give me a detailed tutorial, or case source code, can answer some of my doubts;
1: For obtaining token
I also know what a get request is. I can get token； by entering appid appsecret in the browser to make a GET request.
However, how can I use code to actively get a token in nodejs?
2: After obtaining the token, you can use the token to call WeChat’s interface (such as WeChat’s custom menu interface)
This document should refer to the post request via https (with json data) to WeChat for custom menu. WeChat server will return the result of the request to the developer (what’s the use of the returned result? )
3: There is another problem. The http protocol I used when accessing WeChat
The following is the code for my nodejs to access WeChat. (I used peanut shells to map the local 127.0.0.1:9090 to the http external network address)
However, when calling WeChat interface, I found that I need to use https protocol request (get/post this should have nothing to do with my local server protocol). If I need to use https request, I need to create a service again? This feeling is not right.
4: Forgive me for being a front-end. Since I learned nodejs, I feel like I am into the pit. I can’t climb out all the time. I hope someone can help me with this. Thank you very much.
How did Node.js get into trouble?
The famous request package
npm install request
See the document for usage.