我正在开发iOS UDID检索脚本,遗憾的是我遇到了一个小问题。 您可能知道,要检索iOS UDID,用户必须在iOS设备上安装配置文件。之后,设备响应定义到配置文件中的链接。如果用户直接打开检索链接,将不允许使用错误405方法。与以下链接相同: http://get.udid.io/retrieve/和http://license.if0rce.com/connect/retrieve
/retrieve/index.php中的代码是:
<?php
$data = file_get_contents('php://input');
file_put_contents("data.txt", $data);
?>
我可以通过添加:
来设置自定义错误if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
header("HTTP/1.0 405 Method Not Allowed");
exit(); }
但这不是专业方式。我希望用户得到与上述链接完全相同的错误。
有什么想法吗?
感谢您的帮助:)
答案 0 :(得分:5)
Apache未设置为PHP集状态代码的操作错误文档。 在'custom-msg.php'中,您可以添加要显示的消息。
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
header("HTTP/1.0 405 Method Not Allowed");
include 'custom-msg.php';
exit(); }