简体   繁体   English

HTTP请求PHP监听器

[英]http request php listener

I'm trying to make a php script that can listen to http request from this java class , I tried to use $_POST but it seems that isn't working. 我正在尝试制作一个可以侦听此java类的 http请求的php脚本,我尝试使用$ _POST,但似乎不起作用。 Any help would be appreciated! 任何帮助,将不胜感激!

Try echo file_get_contents("php://input"); 尝试echo file_get_contents("php://input"); to know what is exactly sent by your java class. 知道您的java类确切发送了什么。 $_POST will work only if the data is an urlencoded string. $_POST仅在数据为Urlencoded字符串时有效。 If your javaclass is sending json, you should read it like this: $JSON = json_decode(file_get_contents("php://input"), true); 如果您的javaclass发送的是json,则应这样阅读: $JSON = json_decode(file_get_contents("php://input"), true);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM