在基于PHP的网站上推送通知 [英] Push Notifications On PHP-based Website

查看:293
本文介绍了在基于PHP的网站上推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个网站上工作,该网站将使用PHP(Drupal)编写。外部网站将与其进行交互(例如,推送数据)。



我想做什么,当外部网站推送数据时向用户发送推送通知与他们有关。我不想做任何类型的投票,我更喜欢使用像套接字。



所以一般的过程会像

 数据进入网站,由一些php代码
处理 - 网站将信息发送到某种通知服务器(也由PHP处理)代码)
- 通知服务器将通知推送给用户(大概这必须是某种JavaScript在用户浏览器上运行)

我找不到任何关于如何做这样的事情的好资源。我已经看到了node.js,但我不知道是否是我想要的。我觉得通知服务器将不得不通过套接字与客户端进行通信 - 但是这似乎是一个php套接字与一个javascript套接字交谈,而我去的地方似乎都说这是非常困难或不可能的。 >

有什么方法可以实现这一点?

解决方案

使用推送API (以及Safari的APN),以便即使用户没有浏览您的网站也可以发送通知。



您可以自己实施Push API 或使用 Pushpad (其中有一个 PHP库)。


I am working on a website, which will be written using PHP (Drupal). External websites will interact with it (for example, pushing data in).

What I want to do, is send a push notification to users when an external website pushes in data relevant to them. I don't want to do any sort of polling, I would prefer to use something like sockets.

So the general process would be something like

-Data comes in to website and is handled by some php code
-Website sends information to some sort of notification server (also handled by php code)
-The notification server pushes the notification to the user (presumably this will have to be some sort of javascript running on the user's browser)

I can't really find any good resources on how you could do something like this. I've looked in to node.js but I'm not sure if it's what I want. I feel like the notification server is going to have to communicate over sockets to the client - but that seems like it would be a php socket talking to a javascript socket and everywhere I go seems to say that is quite difficult or impossible.

What are some possible ways to achieve this?

解决方案

You might want to use the Push API (and APNs for Safari), so that notifications are delivered even when the user is not surfing your website.

You can implement the Push API yourself or use a service like Pushpad (which has a PHP library).

这篇关于在基于PHP的网站上推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆