| 123456789101112131415161718192021222324252627282930 |
- const got = require("got");
- const axios = require("axios");
- const APPID = "wxf22759845920b6f3";
- const SECRET = "149873f78958781cd1693c1238deaebc";
- exports.main = async (event, context) => {
- let tokenUrl = `https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=${APPID}&secret=${SECRET}`;
- let res = await got(tokenUrl);
- let { access_token } = JSON.parse(res.body);
- let res0 = await axios.post(
- `https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=${access_token}`,
- {
- template_id: "YTj1RsoMlJW1PFV0JoozU3UTZ4DY-eVvvdK_6OSWBws",
- touser: "oiOWR5ch3L_mD2uYwSemzedDdG8I",
- page: "pages/demo/demo",
- miniprogram_state: "developer",
- lang: "zh_CN",
- data: {
- thing1: { value: "发财998" },
- thing4: { value: "开始装货" },
- thing9: { value: "请穿戴安全装备" },
- time5: { value: "2024-01-01 18:29" },
- },
- }
- );
- return res0;
- };
|