Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/224.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何实现Android向PHP-MySQL发送数据?_Php_Android_Mysql - Fatal编程技术网

如何实现Android向PHP-MySQL发送数据?

如何实现Android向PHP-MySQL发送数据?,php,android,mysql,Php,Android,Mysql,我想知道当Android发布数据时,如何在我的网站上发出通知。 例如:网站有index.php和post.php 然后,我使用POST请求从Android向网站发送数据(通过POST.php)。此时,我想向正在使用index.php的所有用户显示通知 我该怎么做 您需要一个后端(将数据发布到服务器),该后端将为多个用户更新当前前端(index.php演示文稿) 我在这里假设您已经有了一个API,可以在post.php上与后端通信,这允许您传递更新。因此,让我们看看address index.ph

我想知道当Android发布数据时,如何在我的网站上发出通知。 例如:网站有index.phppost.php
然后,我使用POST请求从Android向网站发送数据(通过POST.php)。此时,我想向正在使用index.php的所有用户显示通知

我该怎么做

您需要一个后端(将数据发布到服务器),该后端将为多个用户更新当前前端(index.php演示文稿)

我在这里假设您已经有了一个API,可以在post.php上与后端通信,这允许您传递更新。因此,让我们看看address index.php:


您需要使用Websockets通知客户端更新。一个流行的解决方案是,它通常用于编写需要从客户端接收和发送信息的聊天客户端。

我完全同意@Liam Martin Websockets是一个很好的解决方案,另一个解决方案可能是,在index.php中,您可以创建ajax请求,不断检查是否有来自android设备的新帖子


当你想开发实时应用程序时,你可以尝试一下这一方法

您可以在帖子集中添加一个参数,上面写着“cameFromAndroid=true”。或者别的什么。。。