我正在尝试构建 USSD,运营商正在向我发送 SOAP 请求,但 Apahce 访问日志显示此错误:
OperatorIP - - [时间戳] "POST /ussd HTTP/1.1" 406 344 "-" "bf-am-http"
请求到达
https://example.com/ussd.php
,(使用RewriteRule删除.php),并且ussd.php
文件仅包含这些行:
#Get the inputs and log them to a file to see the contents
$requestBody = trim(file_get_contents('php://input');
file_put_contents("ussdbody.json");
$requestServer = json_encode(array('data' => as $_SERVER));
file_put_contents("ussdserver.json");
echo "Welcome to the ussd";
如果我使用网络浏览器或 Postman 访问
https://example.com/ussd
,ussdbody.json
和 ussdserver.json
将使用正文和服务器内容进行更新。
但是当操作员发送 USSD 请求时,这些文件没有任何变化,我在访问日志中看到的只是上面的错误。
我什至尝试禁用firewalld,认为这可能是防火墙问题,但没有任何改变。
您忘记了创建文件的值,您可以使用以下代码:
$requestBody = trim(file_get_contents('php://input'));
file_put_contents("ussdbody.json",$requestBody);
$requestServer = json_encode(array('data' => $_SERVER));
file_put_contents("ussdserver.json",$requestServer);
echo "Welcome to the ussd";