Google Cloud Platform发布/订阅推送空POST数据

编程入门 行业动态 更新时间:2024-10-27 12:42:00
本文介绍了Google Cloud Platform发布/订阅推送空POST数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

当我尝试在云平台GUI中发送消息时(即,主题->在云平台主题页面),我的端点PHP脚本已触发,但POST数据为空.

因此所有权限和域验证均已就绪.主题和订阅似乎都正确.

我在这里找到了相同的问题,但是

json_decode($HTTP_RAW_POST_DATA);

什么也没做.我也尝试过

$content = null; foreach( $_POST as $k => $v ){ // Just to see what any possible data might be $content .= "Key: $k, Value: $v\n"; } $file = fopen( __DIR__ . '/log.txt', 'w') or die( 'Unable to open file!' ); fwrite( $file, $content ); fclose( $file ); return;

推送端点URL中的

.一样.空的.因此,似乎POST主体为空,我不知道为什么.谁能帮助我指出正确的方向?

解决方案

$HTTP_RAW_POST_DATA是即使在早期版本的PHP7中也已删除,它在php.ini中需要always_populate_raw_post_data.正如您所链接的答案所言,$_POST将不起作用.

代替使用:

json_decode(file_get_contents('php://input'));

When I try to send a message in the cloud platform GUI (i.e. topic -> publish message on the cloud platform topic page) my endpoint PHP script is triggered, but the POST data is empty.

So all the permissions and domain verifications are in place. The topic and subscription both seem to be correct.

I found this same question here but

json_decode($HTTP_RAW_POST_DATA);

did nothing. I also tried

$content = null; foreach( $_POST as $k => $v ){ // Just to see what any possible data might be $content .= "Key: $k, Value: $v\n"; } $file = fopen( __DIR__ . '/log.txt', 'w') or die( 'Unable to open file!' ); fwrite( $file, $content ); fclose( $file ); return;

in the push endpoint URL. Same thing. Empty. So it seems that the POST body is empty and I can't figure out why. Can anyone help point me in the right direction?

解决方案

$HTTP_RAW_POST_DATA was removed in PHP7 even in earlier verisons, it required always_populate_raw_post_data in php.ini. As the answer you linked says, $_POST will not work.

Instead use:

json_decode(file_get_contents('php://input'));

更多推荐

Google Cloud Platform发布/订阅推送空POST数据

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

发布评论

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

>www.elefans.com

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