问题已解决。
-------------------------------------------
问题描述:
1、已经成功开启消息推送功能
2、用户发送客服消息无异常提示
3、服务端记录请求日志,POST内容为空
Time:2022-01-05 03:29:49
Log:array (
0 => //SERVER日志
array (
'USER' => 'www',
'SCRIPT_NAME' => '/index.php',
'REQUEST_URI' => '/magic/push?signature=3e529bd1b49d3eb9ee24d64448bbf9906f67f8e8×tamp=1641349789&nonce=449174906',
'QUERY_STRING' => 'signature=3e529bd1b49d3eb9ee24d64448bbf9906f67f8e8×tamp=1641349789&nonce=449174906',
'REQUEST_METHOD' => 'POST',
'SERVER_PROTOCOL' => 'HTTP/1.1',
'GATEWAY_INTERFACE' => 'CGI/1.1',
'REDIRECT_QUERY_STRING' => 'signature=3e529bd1b49d3eb9ee24d64448bbf9906f67f8e8×tamp=1641349789&nonce=449174906',
'REDIRECT_URL' => '/magic/push',
'REMOTE_PORT' => '40652',
'SERVER_ADMIN' => 'webmasterexample.com',
'CONTEXT_PREFIX' => '',
'REQUEST_SCHEME' => 'https',
'REMOTE_ADDR' => '162.62.81.123',
'SERVER_PORT' => '443',
'SERVER_SOFTWARE' => 'Apache',
'SERVER_SIGNATURE' => 'Apache Server at nm.dasio.com Port 443
',
'CONTENT_TYPE' => 'application/json',
'CONTENT_LENGTH' => '184',
'HTTP_PRAGMA' => 'no-cache',
'HTTP_ACCEPT' => '*/*',
'HTTP_USER_AGENT' => 'Mozilla/4.0',
'proxy-nokeepalive' => '1',
'HTTPS' => 'on',
'gzip-only-text/html' => '1',
'REDIRECT_STATUS' => '200',
'REDIRECT_HTTPS' => 'on',
'REDIRECT_gzip-only-text/html' => '1',
'FCGI_ROLE' => 'RESPONDER',
'PHP_SELF' => '/index.php',
'REQUEST_TIME_FLOAT' => 1641349789.802539,
'REQUEST_TIME' => 1641349789,
),
1 => //GET内容
array (
'signature' => '3e529bd1b49d3eb9ee24d64448bbf9906f67f8e8',
'timestamp' => '1641349789',
'nonce' => '449174906',
),
2 => //POST内容
array (
),
)
4、通过其他方式POST,可以获取到请求参数
Time:2022-01-05 03:39:59
Log:array (
0 => //SERVER
array (
'USER' => 'www',
'SCRIPT_NAME' => '/index.php',
'REQUEST_URI' => '/magic/push',
'QUERY_STRING' => '',
'REQUEST_METHOD' => 'POST',
'SERVER_PROTOCOL' => 'HTTP/1.1',
'GATEWAY_INTERFACE' => 'CGI/1.1',
'REDIRECT_URL' => '/magic/push',
'REMOTE_PORT' => '20015',
'SERVER_ADMIN' => 'webmasterexample.com',
'CONTEXT_PREFIX' => '',
'REQUEST_SCHEME' => 'https',
'REMOTE_ADDR' => '139.198.172.247',
'SERVER_PORT' => '443',
'SERVER_SOFTWARE' => 'Apache',
'SERVER_SIGNATURE' => 'Apache Server at nm.dasio.com Port 443
',
'CONTENT_TYPE' => 'multipart/form-data; boundary=------------------------1acef84b75fbce0c',
'CONTENT_LENGTH' => '141',
'HTTP_COOKIE' => '',
'HTTP_ACCEPT' => '*/*',
'proxy-nokeepalive' => '1',
'HTTPS' => 'on',
'REDIRECT_STATUS' => '200',
'REDIRECT_HTTPS' => 'on',
'FCGI_ROLE' => 'RESPONDER',
'PHP_SELF' => '/index.php',
'REQUEST_TIME_FLOAT' => 1641350399.545334,
'REQUEST_TIME' => 1641350399,
),
1 => //GET
array (
),
2 => //POST
array (
'test' => 'ok',
),
)
推送消息是application/json
低版本PHP中可以用$GLOBALS ['HTTP_RAW_POST_DATA']来获取json数据,PHP7中被废弃,导致无法获取到post过来的数据。修改为file_get_contents("php://input")之后可以正常获取到json数据。