连接主页,以便每次有人登陆该页面时它都会向我的 iPhone 发送推送通知消息

发布于 2024-08-27 15:50:12 字数 633 浏览 4 评论 0原文

我正在寻找一种简单的方法来连接我的网站主页,以便每次有人登陆该页面(仅在浏览器中访问)时都会向我的 iPhone 发送推送通知消息。我知道这可能会变得很烦人!

目前,我使用 cron 和curl 定期向我的 iPhone 发送通知,以检查站点/RSS 提要是否有更改,然后发送到 Prowl API,后者又将其发送到我的 iPhone - 就像这样:

curl https://prowl.weks.net/publicapi/add -F apikey=$apikey -F priority=$priority -F application="$app" -F event="$eventname" -F description="$description"

我可以使用以下 HTML 做类似的事情吗?主页 - 在我的服务器上调用一个脚本,该脚本又会触发上面类似的curl请求?也许使用 Javascript 或 PHP?理想情况下,我希望网页的加载和渲染不会被调用中断。

向 Prowl - http://prowl.weks.net/api.php 致敬flx.me 我用这两者来制作我已经在工作的东西。

I looking for a simple way to wire the homepage of my website so that it fires off a Push notification message to my iPhone every time someone lands on the page (just visiting in their browser). I'm aware this could become annoying!

I currently send regular notifications to my iPhone using cron and curl to check sites / RSS feeds for change and then fire to to the Prowl API who in turn send it to my iPhone - like so:

curl https://prowl.weks.net/publicapi/add -F apikey=$apikey -F priority=$priority -F application="$app" -F event="$eventname" -F description="$description"

Could I do something similar from with the HTML of the homepage - call a script on my server which in turn fires a similar curl request above? Maybe with Javascript or PHP? Ideally I'd like the loading and rendering of me webpage to be uninterrupted by the call.

Hat tip to Prowl - http://prowl.weks.net/api.php and to flx.me
Both of which I use to make what I have already working.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷乱花海 2024-09-03 15:50:12

如果安装了 PHP 的 cURL 库,则可以直接从 PHP 执行该命令(请参阅 http:// php.net/manual/en/book.curl.phphttp://curl. haxx.se/libcurl/php/):

<?php
// This is at the top of the HTML page
// (although you could put it anywhere)
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://prowl.weks.net/publicapi/add");
// The next 2 commands assume that you are sending a POST request
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "apikey=$apikey,priority=$priority&application=$app&event=$eventname&description=$description");
curl_exec ($ch);
curl_close ($ch);
?>
<html>
...

此外,您可以使用 PHP 的 系统exec 或类似函数来执行 cURL 命令:

<?php
// This is at the top of the HTML page
// (although you could put it anywhere)
exec('curl https://prowl.weks.net/publicapi/add -F apikey=$apikey -F priority=$priority -F application="$app" -F event="$eventname" -F description="$description"');
?>
<html>
...

You can execute the command directly from PHP if you have PHP's cURL library installed (see http://php.net/manual/en/book.curl.php and http://curl.haxx.se/libcurl/php/):

<?php
// This is at the top of the HTML page
// (although you could put it anywhere)
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://prowl.weks.net/publicapi/add");
// The next 2 commands assume that you are sending a POST request
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "apikey=$apikey,priority=$priority&application=$app&event=$eventname&description=$description");
curl_exec ($ch);
curl_close ($ch);
?>
<html>
...

Additionally, you could use PHP's system, exec, or similar function to execute the cURL command:

<?php
// This is at the top of the HTML page
// (although you could put it anywhere)
exec('curl https://prowl.weks.net/publicapi/add -F apikey=$apikey -F priority=$priority -F application="$app" -F event="$eventname" -F description="$description"');
?>
<html>
...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文