且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用POST从PHP向树莓派的Python脚本发送数据

更新时间:2022-11-26 12:22:57

因此,当前计划的问题是您必须能够将张贴到.

So the problem with your current plan is that you must be able to POST to somewhere.

在将pi发布到服务器的情况下,我们将发布到 http://jawad.meswatts.fr/sous/api.php

In the case of the pi posting to the server, we are posting to http://jawad.meswatts.fr/sous/api.php

但是如果服务器想发布到pi.它会发布到哪里?pi在任何域名或公共IP上均不公开.(可以通过这种方式进行设置,但我不建议初学者使用.)

But if the server wanted to post to the pi. Where would it post to? The pi isn't publicly available at any domain name or public IP. (Its possible to set it up this way, but I wouldn't recommend it for beginners).

相反,我将从其他所有人过去如何解决此问题开始.让pi向服务器上的另一个位置发出GET请求.该函数将返回本应发布的信息.这样,服务器就永远不会尝试找到pi.它只是等到被告知存储某些信息(POST)或被问到某些信息是什么(GET)为止.

Instead I would start with how everyone else has solved this in the past. Have the pi make a GET request to another location on the server. This function would return the information that would have been posted. In this way, the server never tries to find the pi. It just waits until it is told to store some information (POST) or until it is asked what some information is (GET).