Sometimes the blog content will change. The first blog is the latest, and other blog addresses may not be synchronized. Check it carefully.
https://blog.zysicyj.top
Open source address: https://github.com/zysicyj/Vitality-reminder
Vitality reminder
Use the WeChat subscription account to send scheduled messages to your girlfriend every day.
If you don’t have a girlfriend yet, this can help you get out of singles as soon as possible.
Show results
-
Send vitality reminders regularly every day (the sending time is configurable) -
Special reminders will also be sent at special times. Currently, there are: payday, anniversary together, and birthday. Will be gradually increased later -
Those who have the ability to change can modify the code themselves to achieve more reminders
Steps for usage
-
Clone the repository locally -
npm install
Orcnpm install
install dependent configuration files -
Modify the subscription account configuration file of config.js -
Modify fnc.js personal important information node configuration file -
Create a subscription account test account and configure a group message template -
Upload the code file to the personal server, first bind a subscription number, and obtain the accept_token -
Set the designated sending person and the designated sending time -
The server hangs the app.js script and the configuration is complete!
Modify configuration config.js
-
Both appid and AppSecret can be obtained by successfully applying for a WeChat public account. However, if you apply for a public account in the name of an individual, you cannot obtain the permissions for this interface. At this time, you can use a test to develop the public account. There are almost all interface permissions on it. WeChat public platform interface test account application URL: https://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=sandbox/login.
-
第三方天气接口我是在聚合数据平台申请的,是免费的接口,这里替换成各自的聚合数据接口的天气接口key即可聚合数据 地址:https://www.juhe.cn/docs?bd_vid=7775114093417537769
-
这里就有了这些基本的id,直接复制即可。
修改fnc.js
-
修改base对象的birthday、love、pay字段替换为个人的即可
创建微信公众号测试号,配置群发消息模板
微信公众平台接口测试帐号申请 网址:https://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=sandbox/login。
-
元气提醒
{ {dateTime.DATA}}
今天是 我们相恋的第{ {love.DATA}}天
距离上交工资还有{ {pay.DATA}}天
距离你的生日还有{ {birthday.DATA}}天
今日天气 { {weather.DATA}}
今日温度 { {temp.DATA}}度
空气湿度 { {humidity.DATA}}
风向 { {wind.DATA}}
每日一句
{ {message.DATA}} -
工资模板
{ {dateTime.DATA}}
亲爱的,今天要发工资了,咱们账户上又多了一笔!注意查收~! -
生日模板
{ {dateTime.DATA}}
听说今天是你人生当中第 { {individual.DATA}} 个生日?
天呐, 我差点忘记!因为你永远18岁~。
尽管,日历告诉我:你又涨了一岁,但你还是那个天真可爱的小仙女,生日快乐! -
纪念日模板
{ {dateTime.DATA}}
今天是在一起{ {anniversary.DATA}}周年纪念日。
经历了风风雨雨,最终依然走在一起,很幸运,很幸福!我们的小家庭要一直幸福下去。
这里的模板id就是分别对应的config.js的那四个模板id
获取公众号的accect_token的权限
accect_token是获取我们访问公众号接口的一个必填字段,需要先获取。获取这个需要有url,所以需要准备一台个人的云服务器
-
将整个项目放到云服务器上 -
进入这个项目的目录 -
检查config.js文件中的token字段的值是不是和公众号接口配置中的值是一样的,需要时一致的。 -
用node运行一下connect.js脚本 -
提交一下接口配置信息的认证。等待页面提示成功 -
取消node的connect.js脚本
此处我省略了一些内容,connect.js监听的是8080,但是接口配置只能是80端口或者443端口,所以基于这个需要做个接口的转发,利用宝塔面板可以很容易的实现接口的反向代理。
设置指定发送的人员
进入api.js,修改两个template对象的touser字段
-
Is it not included in the configuration file because of the possible need to send it to different people?
Enter app.js and modify the first parameter of the CromJob constructor to set the daily sending time.
Use pm2 to run app.js script
-
Install pm2 first -
Enter the project directory -
run pm2 start app.js
test
If the above steps are completed, you can manually enter url:8080/base
and in the browser url:8080/base/important
, or adjust the listening time of app.js to the upcoming time to test
Summarize
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 the template information regularly every day.
At present, the content of the template is limited, and the content of the template will be continuously added. If you are interested, capable friends can also modify the code to achieve more functions.
Change log
-
Added custom love words (2022.10.05)
You can customize
love_message
the daily love words in config.js, and randomly pick one out and send it every day.
This article is published by mdnice multi-platform