1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| async function getAccessToken() { const resp = await fetch( "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=XXX&secret=XXX", ); const data = await resp.json(); return data.access_token; }
async function genMiniAppURL() { const accessToken = await getAccessToken(); const resp = await fetch( `https://api.weixin.qq.com/wxa/generate_urllink?access_token=${accessToken}`, { method: "POST", body: JSON.stringify({ "is_expire": true, "expire_type": 0, "expire_time": new Date().getTime() + 1000 * 60 * 60 * 24 * 30, }), }, ); const data = await resp.json(); return data.url_link; }
async function reportToFeishu() { const url = await genMiniAppURL(); await fetch( "https://open.feishu.cn/open-apis/bot/v2/hook/XXX", { method: "POST", body: JSON.stringify({ msg_type: "interactive", card: { config: { wide_screen_mode: true, enable_forward: true, }, header: { title: { content: "小程序链接", }, }, elements: [ { tag: "div", text: { content: `小程序链接: ${url}`, }, }, ], }, }), }, ); }
async function work(){ console.log("Fetch Miniapp URL."); reportToFeishu(); }
Deno.cron("Fetch Miniapp URL", "0 11 1 * *", async () => { await work(); });
work();
|