我在从.mobileconfig获取设备信息时遇到问题。 以下是我已经完成的步骤:
device.mobileconfig:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PayloadContent</key>
<dict>
<key>URL</key>
<string>http://mywebsite.ir/retrieve/get.php</string>
<key>DeviceAttributes</key>
<array>
<string>UDID</string>
<string>VERSION</string>
<string>PRODUCT</string>
</array>
</dict>
<key>PayloadOrganization</key>
<string>MyWebsite.ir</string>
<key>PayloadDisplayName</key>
<string>Device Information</string>
<key>PayloadVersion</key>
<integer>1</integer>
<key>PayloadUUID</key>
<string>fab376e5-b5bc-4d8c-829e-e90865f990c9</string>
<key>PayloadIdentifier</key>
<string>com.MyWebsite.mobileconfig.device-information</string>
<key>PayloadDescription</key>
<string>Device information</string>
<key>PayloadType</key>
<string>Profile Service</string>
</dict>
</plist>
当我在iOS设备上安装配置文件时,它将被安装并重定向到mywebsite.ir/retrieve/get.php
get.php的内容是:
$data = file_get_contents('php://input');
file_put_contents("data.txt", $data);
$plistBegin = '<?xml version="1.0"';
$plistEnd = '</plist>';
$pos1 = strpos($data, $plistBegin);
$pos2 = strpos($data, $plistEnd);
$data2 = substr ($data,$pos1,$pos2-$pos1);
$xml = xml_parser_create();
xml_parse_into_struct($xml, $data2, $vs);
xml_parser_free($xml);
$UDID = "";
$DEVICE_PRODUCT = "";
$DEVICE_VERSION = "";
$iterator = 0;
$arrayCleaned = array();
foreach($vs as $v){
if($v['level'] == 3 && $v['type'] == 'complete'){
$arrayCleaned[]= $v;
}
$iterator++;
}
$data = "";
$iterator = 0;
foreach($arrayCleaned as $elem){
$data .= "\n==".$elem['tag']." -> ".$elem['value']."<br/>";
switch ($elem['value']) {
case "DEVICE_NAME":
$DEVICE_NAME = $arrayCleaned[$iterator+1]['value'];
break;
case "PRODUCT":
$DEVICE_PRODUCT = $arrayCleaned[$iterator+1]['value'];
break;
case "UDID":
$UDID = $arrayCleaned[$iterator+1]['value'];
break;
case "VERSION":
$DEVICE_VERSION = $arrayCleaned[$iterator+1]['value'];
break;
}
$iterator++;
}
$params = "UDID: ".$UDID."\n"."DEVICE_PRODUCT: ".$DEVICE_PRODUCT."\n"."DEVICE_VERSION: ".$DEVICE_VERSION;
file_put_contents("data2.txt", $params);
header("Location: http://mywebsite.ir/retrieve/msg?params=done");
最后,两个文件(data.txt和data2.txt)存储在/ retrive上,但两者都是空的。似乎没有任何数据从iOS设备发送到脚本,因为data.txt为空,而它必须包含一些用于解析的数据。但是,正在安装配置文件时没有错误并被重定向到脚本。
有什么想法吗?
我刚刚发现了问题所在。 由于安全问题,我的服务器已经禁用了一些PHP功能。我有这个代码,并希望将其更改为“Curl”和“readfile”函数。有人可以帮我吗?
<?php
$data = file_get_contents('php://input');
file_put_contents("dat.txt", $data);
?>