从 .mobileconfig 获取设备 UDID
我正在尝试编写类似于 http://whatismyudid.com/ 的函数,然后获得批准,将返回用户UDID 并将其存储到数据库中以供该用户将来参考。
我编写了一个 .mobileconfig xml 文档,可以在配置文件安装程序中打开,但当我告诉它安装配置文件时,它会响应 [alert] Invalid Profile
但没有警报正文。没有描述,没有代码,没有帮助。
我是移动配置游戏的新手,因此任何帮助都会让我兴奋不已。
这是我的配置文件:
<?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://apps.mortlabs.com/device/retrieve.php</string>
<key>DeviceAttributes</key>
<array>
<string>UDID</string>
<string>IMEI</string>
<string>ICCID</string>
<string>VERSION</string>
<string>PRODUCT</string>
</array>
</dict>
<key>PayloadOrganization</key>
<string>MortLabs.com</string>
<key>PayloadDisplayName</key>
<string>Profile Service</string>
<key>PayloadVersion</key>
<integer>1</integer>
<key>PayloadUUID</key>
<string>B958E359-34C2-42F4-BD0C-C985E6D5376B</string>
<key>PayloadIdentifier</key>
<string>com.mortlabs.profile-service</string>
<key>PayloadDescription</key>
<string>This temporary profile will be used to find and display your current device's UDID.</string>
<key>PayloadType</key>
<string>Profile Service</string>
</dict>
</plist>
通过导航到 http://apps.mortlabs.com/ 来初始化配置文件device/enroll.php 与移动 Safari
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我发现通过使用上述内容,Ipad/Iphone 正在与 Apache 进行对话 - Kyle2011 的帖子 https://discussions.apple.com/thread/3089948?start=0&tstart=0 填写解决方案的其余部分。
基本上,在retrieve.php页面的底部,您需要使用类似于以下的行将浏览器重定向到目录:-
其中注册是一个目录-然后调用DirectoryIndex(通常是index.php),然后可以显示给你的用户的东西。
要填充 $params 变量,您需要在retrieve.php 脚本顶部添加以下行,
然后您可以解析 $data 字符串以获取您需要的内容(尝试
file_put_contents("data.txt", $data);
或 Kyle2011 的示例)我还通过在 Mac 终端中使用
udidgen
将 Payload UDID 更改为不同的内容,而不仅仅是使用 Whatismyudid.com 的。更新:从 iOS 7.1 开始,一些文件(.plist IIRC)需要通过 https:// 提供 - 如果所有内容都通过 http:// 提供,它们将无法安装 - 可能最好通过 https:// 提供所有内容,包括 .ipa https:// 以确保 Apple 方面未来的更改不会造成问题。
I found that by using the above that Apache was being talked to by the Ipad/Iphone - The post by Kyle2011 at https://discussions.apple.com/thread/3089948?start=0&tstart=0 filled in the rest of the solution.
Basically at the bottom of the retrieve.php page you need to redirect the browser to a directory by using a line similar to the following:-
Where enrolment is a directory - this then calls the DirectoryIndex (typically index.php) which can then display stuff to your user.
To populate the $params variable you need the following line at the top of your retrieve.php script
You can then parse the $data string to get what you need (try
file_put_contents("data.txt", $data);
or Kyle2011's example)I also changed the Payload UDID to something different by using
udidgen
in a terminal on a Mac rather than just using whatismyudid.com's.Update: From iOS 7.1 some of the files (the .plist IIRC) need to be served over https:// - they will fail to install if everything is served over http:// - probably best to serve everything including the .ipa over https:// to ensure future changes on Apple's side don't cause a problem.
请注意最后一页(文件夹)。
如果您想使用页面脚本代替文件夹进行最终重定向。
你可以改变这个:
经过
来源:php.net 手册上的标头函数< /a>
工作了!
Note about the last page ( FOLDER ).
If you want to use a page script for final redirection in place of a folder.
you can change this :
by
Source : header function on php.net manual
it's work !
尝试将 URL 设置为不带 .php 扩展名的地址。这为我解决了问题。
现在我唯一的问题是我不知道如何检索从 iOS 设备发送到我的服务器的数据。
它似乎不在 $_POST 变量中。
Try setting the URL to an address without .php extension. This solved the problem for me.
Now my only problem is that I can't find out how to retrieve the data sent from the iOS device to my server.
It does not seem to be in the $_POST variable.
您收到的错误是因为 iOS 期望您的配置文件服务 URL(它将 UDID 发送到的 URL)返回配置配置文件(即
.mobileconfig
文件)。我目前捕获设备 UDID,但不返回此配置文件;我的设备生成您描述的警报,但数据位于我的服务器上。作为参考,这是我用来捕获数据的(非常)简单的 PHP 文件:
这里的关键是使用
$HTTP_RAW_POST_DATA
变量来捕获与发送时完全相同的 HTTP 请求正文,而不尝试解析将其转换为通常的名称/值对。我建议此时阅读文档,但是它确实没有告诉你太多。安全提示:无论用户在请求正文中发送什么内容,您都将写入服务器上的文件。如果用户决定发送 shell 脚本、PHP 文件或其他可执行内容,然后访问您创建的文件的 URL,他们就可以执行刚刚上传到您的 Web 服务器上的代码。因此,确保您写入的文件无法通过 HTTP 访问! (
.htaccess
文件就可以解决这个问题,或者写入网络根目录之外的某个位置。)The error you're getting is because iOS expects your profile service URL (the one it sends its UDID to) to return a configuration profile (i.e. a
.mobileconfig
file). I currently capture device UDIDs without returning this profile; my devices generate the alert you describe but the data is on my server.For reference, here's the (very) simple PHP file I use to capture the data:
The key here is the use of the
$HTTP_RAW_POST_DATA
variable to capture the HTTP request body exactly as sent, without attempting to parse it into the usual name/value pairs. I'd suggest reading the documentation at this point, but it really doesn't tell you much.Security tip: whatever the user sends in the request body, you're writing to a file on your server. If the user decides to send a shell script, PHP file, or other executable content, then visits the URL of the file you create, they can execute the code the just uploaded on your web server. So, make sure the file you write to can't be accessed via HTTP! (A
.htaccess
file would do the trick, or write to somewhere outside the web root.)