Vigour to remind

Make use of wechat subscription number to push messages to my girlfriend every day. Who says we programmers are straight? They don’t understand romance!

If you do not have a girlfriend of this can wish you a helping hand, as soon as possible out of the single.

Nuggets of the first article in the process of fishing to complete!

Project address gitee.com/jimmyxuexue…

V1.0.0

This piece of public number has always been my weakest part, a lot of configuration, lucky to see a Daniel to her girlfriend to write, happened to catch up with my girlfriend’s birthday, also followed the article written down and deployment completed, girlfriend also feel good, really happy to die. !!!!! Iwhao got his approval of the original post address of Daniel’s article. I will also record and summarize it!

Results show

  • Send qi Qi reminder regularly every day (the sending time can be configured)
  • Special reminders are also sent on special occasions, including paydays, anniversaries and birthdays. There will be more after that
  • Those with the ability to change the code themselves can implement more reminders

Using the step

  • Clone the repository locally
  • npm installorcnpm installInstall the dependency profile
  • Modify the subscription number configuration file of config.js
  • Modify the fnC. js personal Important information node configuration file
  • Create a subscription number test number and configure a group messaging template
  • Upload the code file to the personal server, bind a subscription number first, get accect_token
  • Sets the person to send and the time to send
  • Install app.js script on the server and the configuration is complete!

Modify config. Js

  • Appid and AppSecret can be obtained if the application for wechat public account is successful, but the group interface can not be obtained if the public account is applied in the name of an individual. At this time, a test can be used to develop the public account, which has almost all the interface permissions. WeChat public platform interface test account application url: mp.weixin.qq.com/debug/cgi-b…
  • I applied for the third-party weather interface on the aggregated data platform. It is a free interface. Here, replace the weather interface key of the respective aggregated data interface with the aggregated data address: www.juhe.cn/docs?bd_vid…

  • So there you have these basic ids, just copy them.

Modify as FNC. Js

  • Change the birthday, love, and pay fields of the base object to individual fields

Create a wechat public account test number and configure the group message template

WeChat public platform interface test account application url: mp.weixin.qq.com/debug/cgi-b…

  • Vigour to remind

    {{datetime. DATA}} {{love.DATA}} {{pay.DATA}} {{birthday.DATA}} {{weather DATA {{wind.DATA}} {{wind.DATA}} {{message.Copy the code
  • Salary template

    {{datetime. DATA}} Dear, today is payday, we have another sum in the account! Note check ~!Copy the code
  • Birthday template

    {{datetime. DATA}} I heard that today is your {{individual.DATA}} birthday? Oh, my God, I almost forgot! Because you're always 18. Although, the calendar tells me: you rose a year, but you are still that naive lovely little fairy, happy birthday!Copy the code
  • Memorial Day template

    {{datetime. DATA}} today is the anniversary of being together {{tartary.data}}. Through ups and downs, we are still together, very lucky and happy! Our little family will always be happy.Copy the code

The template ids here are the four template ids corresponding to config.js

Access to the accect_token of the public account

Accect_token is a required field to access our public account interface. You need a URL to get this, so you need a personal cloud server

  • Put the entire project in the cloud
  • Go to the directory for this project
  • Check whether the token field value in the config.js file is the same as that in the public number interface configuration.
  • Run the connect.js script with Node
  • Submit the authentication of interface configuration information. Wait until the page displays a success message
  • Cancel the connect.js script for Node

I have omitted some content here, connect.js listens to 8080, but the interface configuration can only be port 80 or 443, so based on this need to do an interface forward, using the pagoda panel can easily implement the reverse proxy of the interface.

Sets the person specified to send

Go to api.js and change the touser fields of the two Template objects

  • I didn’t write it in the configuration file because THERE might be requirements that I would send to different people, right?

Go to app.js and modify the first parameter of the CromJob constructor to set the daily send time.

Run app.js script with PM2

  • Install the PM2 first
  • Enter the project directory
  • runpm2 start app.js

test

If all the above steps are completed, you can manually enter url:8080/base and URL :8080/base/important in the browser, or adjust app.js listening time to the upcoming time to test

conclusion

The essence of this project is to write an interface that can access the public account group message template, and then use CronJob to send template information on a daily basis.

Currently the content of the template is limited, the content of the template will continue to add, capable partners if interested can also modify the code to achieve more functions.

Through this is mainly to learn the public number interface call, as well as some server knowledge, such as reverse proxy, FTP, port configuration and so on.