Google Cloud发布/订阅推送消息

编程入门 行业动态 更新时间:2024-10-26 16:28:53
本文介绍了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.

每当我尝试从 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发布/订阅推送消息

本文发布于:2023-11-24 11:15:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1624980.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:消息   Google   Cloud

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!