Analysis of nodejs WeChat public account development-1. Access to WeChat public account

Source: Internet
Author: User
This article mainly introduces nodejs public account development-1. it is of practical value to access the public account. For more information about nodejs public account development, see the following article. it is of practical value to access the public account. For more information, see

Access to the public account is the first step in development. if everything starts hard, take the first step, and the next step will be wider.

1. use of the public platform test account

Log on to the public platform. because many developers do not have an authenticated public account, you can usePublic platform test accountTo test the function, its advantage is to be able to test the vast majority of the functions of the public account, not limited by the certification threshold.

Now, write the app. js code:

'Use strict 'var Koa = require ('koa'); var sha1 = require ('sha1'); var config = {wechat: {appID :'... ', // enter your own appID appSecret :'... ', // enter your own appSecret token :'... '// enter your own token}; var app = new Koa (); app. use (function * (next) {var token = config. wechat. token; var signature = this. query. signature; var nonce = this. query. nonce; var timestamp = this. query. timestamp; var echostr = this. query. echostr; var Str = [token, timestamp, nonce]. sort (). join (''); // Sort by dictionary and splice the string var sha = sha1 (str); // encrypt this. body = (sha = signature )? Echostr + '': 'failed'; // compare and return result}); app. listen (8080 );

5. configure the public account information for the test

After the code is compiled, the configuration is now complete. Enterlt --port 8080Start localtunnel to obtain externally accessibleURL:

So far, we have opened the door to public account development. Next, we will continue to explore the nodejs public account development journey.

The above is the analysis of nodejs public number Development-1. access details of the public number, please pay attention to other related articles on php Chinese network!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.