我目前已经在google云平台上成功设置了主题和订阅,并且已经通过google验证了我的网站并将该域添加到了GCP中.
I currently have successfully set up a topic and subscription in the google cloud platform, and have verified my site with google and added the domain to the GCP.
每当我尝试从 console.cloud发送测试消息时. google/cloudpubsub/topics/subscription_sync ,我配置的端点会收到某物,但POST变量为空.这是我到目前为止在php中使用的代码,它只是对POST变量进行简单的记录(以后会在我的日志中显示为空).
Whenever I try to send a test message from console.cloud.google/cloudpubsub/topics/subscription_sync, the endpoint I configured receives something, but the POST variable is empty. Here is the code I have so far in php, it just does simple logging of the POST variable (which later shows up in my logs as empty.)
require_once 'EventPersister.class.php'; $eventPersister = new EventPersister(EventPersister::GOOGLE_WEBHOOKS); $eventPersister->Persist($_POST);要使POST数据正确显示,我需要做些特殊的事情吗?
Is there anything special I need to do to get the POST data to show up properly?
推荐答案对于遇到此问题的任何人,这是因为POST数据以json格式发送.因此,除了查看$ _POST之外,您还需要做
For anyone that's having trouble with this, it's because the POST data is sent in a json format. So instead of looking at $_POST, you have to do
json_decode(file_get_contents('php://input'));....那应该可以.或者,您可以
....and that should work. Alternatively, you can do
json_decode($HTTP_RAW_POST_DATA);获取数据.
更多推荐
Google Cloud发布/订阅推送消息
发布评论