Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/251.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php-使用php处理应用程序/x-www-form-urlencoded POST请求_Php_Json_Content Type_Urlencode_Urldecode - Fatal编程技术网

php-使用php处理应用程序/x-www-form-urlencoded POST请求

php-使用php处理应用程序/x-www-form-urlencoded POST请求,php,json,content-type,urlencode,urldecode,Php,Json,Content Type,Urlencode,Urldecode,我正在尝试使用PHP处理应用程序/x-www-form-urlencodedPOST请求。客户端以以下格式发送请求: POST /index.php User-Agent: Android/4.0 Content-Type: application/x-www-form-urlencoded Accept-Encoding: gzip action=Settings&device_id=2112121&app_version=420 服务器的响应必须如下所示: { "

我正在尝试使用PHP处理
应用程序/x-www-form-urlencoded
POST请求。客户端以以下格式发送请求:

POST /index.php User-Agent: Android/4.0 
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip
action=Settings&device_id=2112121&app_version=420
服务器的响应必须如下所示:

{
    "action": "Settings",
    "data": {
        "entries": {
            "service_enabled": "true"
        }
    },
    "data_format": "json"
}

对服务器端的
index.php
有什么想法吗?

试试这个
$\u POST=json\u decode(file\u get\u contents(“php://input"(对),

向我们展示您迄今为止的尝试,我们将帮助您解决遇到的任何问题。不,我不知道。
“数据”
从哪里来?我们应该如何处理
设备\u id=211221&app\u version=420
?这既不会生成响应(正如OP建议的分配),也不会在他的示例中发明额外的数据。