树洞剪藏#剪藏#树洞剪藏

自用挪车二维码,可实现微信通知和拨打电话 - 开发调优 / 开发调优, Lv1 - LINUX DO

2024 年 11 月 15 日1 分钟
分享Twitter / XTelegram微博

同步来源:树洞剪藏 源站剪藏 ID:81 原文地址:https://linux.do/t/topic/254701

打开原文 · 打开源站剪藏快照


自用挪车二维码,可实现微信通知和拨打电话 - 开发调优 / 开发调优, Lv1 - LINUX DO

{ event.respondWith(handleRequest(event.request)) }) async function handleRequest(request) { const phone = '139xxxxxxxx' // 车主的手机号 const wxpusherAppToken = 'AT_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx' // Wxpusher APP Token const wxpusherUIDs = ['UID_sxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'] // 车主的UIDs const htmlContent = ..."> { event.respondWith(handleRequest(event.request)) }) async function handleRequest(request) { const phone = '139xxxxxxxx' // 车主的手机号 const wxpusherAppToken = 'AT_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx' // Wxpusher APP Token const wxpusherUIDs = ['UID_sxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'] // 车主的UIDs const htmlContent = ...">

跳到主要内容

话题

我的帖子

关于

友链

文档

更多

外部链接

Status

Connect

Channel

Telegram

Shared Chat

类别

开发调优

资源荟萃

文档共建

跳蚤市场

前沿快讯

福利羊毛

搞七捻三

运营反馈

深海幽域

所有类别

标签

抽奖

公告

精华神帖

快问快答

人工智能

所有标签

消息

收件箱

频道

常规频道

直接消息

聊天

真诚 、 友善 、 团结 、 专业 ,共建你我引以为荣之社区。 《常见问题解答》

自用挪车二维码,可实现微信通知和拨打电话

开发调优 开发调优, Lv1

网络安全 软件调试

11月 9 日

1 / 172

11月 9 日

返回

18 小时

热门回复

前排围观支持一下 感谢分享大佬厉害啊 有点厉害支持~~

Ant

3 6 天 #1

可以部署到 cloudflare 的 wokers,自定义变量 phone 和 wxpusherAppToken、wxpusherUIDs 或者直接在源码修改就行

实现推送到微信

也可以把第二个 button 注释掉,只保留微信通知

可以绑定一个域名实现 cdn 加速,把网址转换成二维码,打印即可

image 1600×730 78 KB

addEventListener('fetch', event => { event.respondWith(handleRequest(event.request)) })

async function handleRequest(request) { const phone = '139xxxxxxxx' // 车主的手机号 const wxpusherAppToken = 'AT_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx' // Wxpusher APP Token const wxpusherUIDs = ['UID_sxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'] // 车主的UIDs

const htmlContent = `

< html lang = "zh-CN" > < head > < meta charset = "UTF-8" > < meta name = "viewport" content = "width=device-width, initial-scale=1.0" > < title > 通知车主挪车 </ title > < style >

  • { box-sizing : border-box; margin : 0 ; padding : 0 ; } body { font-family : Arial, sans-serif; display : flex; align-items : center; justify-content : center; height : 100vh ; background : #f0f2f5 ; color : #333 ; } .container { text-align : center; padding : 20px ; width : 100% ; max-width : 400px ; border-radius : 8px ; box-shadow : 0 4px 8px rgba ( 0 , 0 , 0 , 0.2 ); background : #fff ; } h1 { font-size : 24px ; margin-bottom : 20px ; color : #007bff ; } p { margin-bottom : 20px ; font-size : 16px ; color : #555 ; } button { width : 100% ; padding : 15px ; margin : 10px 0 ; font-size : 18px ; font-weight : bold; color : #fff ; border : none; border-radius : 6px ; cursor : pointer; transition : background 0.3s ; } .notify-btn { background : #28a745 ; } .notify-btn :hover { background : #218838 ; } .call-btn { background : #17a2b8 ; } .call-btn :hover { background : #138496 ; } </ style > </ head > < body > < div class = "container" > < h1 > 通知车主挪车 </ h1 > < p > 如需通知车主,请点击以下按钮 </ p > < button class = "notify-btn" onclick = "notifyOwner()" > 通知车主挪车 </ button > < button class = "call-btn" onclick = "callOwner()" > 拨打车主电话 </ button > </ div >

< script > // 调用 Wxpusher API 来发送挪车通知 function notifyOwner ( ) { fetch ( "https://wxpusher.zjiecode.com/api/send/message" , { method : "POST" , headers : { "Content-Type" : "application/json" }, body : JSON . stringify ({ appToken : "${wxpusherAppToken}" , content : "您好,有人需要您挪车,请及时处理。" , contentType : 1 , uids : ${ JSON . stringify (wxpusherUIDs)} }) }) . then ( response => response. json ()) . then ( data => { if (data. code === 1000 ) { alert ( "通知已发送!" ); } else { alert ( "通知发送失败,请稍后重试。" ); } }) . catch ( error => { console . error ( "Error sending notification:" , error); alert ( "通知发送出错,请检查网络连接。" ); }); }

// 拨打车主电话 function callOwner ( ) { window . location . href = "tel:${phone}" ; } </ script > </ body > </ html > `

return new Response(htmlContent, { headers: { 'Content-Type': 'text/html;charset=UTF-8' }, }) }

1 个回复

heart

+1

clap

438

回复

【感谢大佬的奉献】【V1.3】升级版来咯,自用挪车二维码,可实现微信通知和拨打电话 31

4.3k

浏览量

930

7

链接

132

用户

10

7

4

3

3

阅读时间

12 分钟

热门回复

Ant

6 天 #2

image 1870×838 219 KB

感谢赛博菩萨

4 个回复

heart

clap

laughing

46

回复

流浪谷 llg 文化宣导员

6 天 #3

感觉很强大的样子,感谢佬友的无私分享!

4 回复

dfg57 smooth

6 天 #4

未曾设想的道路

4 回复

zhc zhhc88 文化宣导员

6 天 #5

感谢分享大佬厉害啊

17 回复

CowBoy haso2007

6 天 #6

佬,这是实用得很呀

8 回复

dashabi

6 天 #7

万一有人恶意用微信通知轰炸叻 3 个回复

8 回复

ttpy 浴火重生

6 天 #8

感谢佬友分析,待会就试下

3 回复

Ant dashabi 6 天 #9

也可以把第二个 button 注释掉,只保留微信通知 1 个回复

11 回复

Ant dashabi 6 天 #10

那就加个通知限制,1 分钟后才能再次通知

22 回复

lkainan 种子用户

6 天 #11

不错 不错呀。 以前记得有企业搞这种,收费的。 1 个回复

6 回复

lkainan 种子用户

Ant 6 天 #12

加一个验证,防止被恶意请求

5 回复

锐评 GeminiGo 浴火重生

6 天 #13

佬友简直是超级有才气,简直太厉害了!

6 回复

Coker 文化宣导员

6 天 #14

有想法,感谢佬友分享!

3 回复

大帅哥 handsome 种子用户

6 天 #15

啊?还有这种操作?

7 回复

caoayu 浴火重生

6 天 #16

感谢分享

8 回复

xmjer 圆圆满满

6 天 #17

感谢大佬分享

3 回复

Boom crazyboom

6 天 #18

感谢大佬思路分享

3 回复

0x26e7d 圆圆满满

6 天 #19

收藏下,学会了,就差一辆 su7 ultra

5 回复

ciu ccdan

6 天 #20

好啊,不错的主意

6 回复

开始阅读 启用自动点赞

楼主

等级

相关文章