Google Cloud发布/订阅推送消息-空POST [英] Google Cloud Pub/Sub Push Messages - Empty POST

查看:263
本文介绍了Google Cloud发布/订阅推送消息-空POST的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前已经在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.

每当我尝试从 https://console.cloud发送测试消息时. google.com/cloudpubsub/topics/subscription_sync ,我配置的端点会收到某物,但POST变量为空.这是我到目前为止在php中使用的代码,它只是对POST变量进行简单的记录(以后会在我的日志中显示为空).

Whenever I try to send a test message from https://console.cloud.google.com/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发布/订阅推送消息-空POST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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