You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

I cannot get the informations of response from iPhone device in Phase2

Hello All,


I'm continuing the Archived post https://discussions.apple.com/thread/2260676, I can't get it worked


I'm trying to use the OTA mobileconfig to retrive the UDID of users, I made a mobileconfig and I manage to install it ont iDevice and after installing, it call my PHP script back but with no datas (in the GET, POST, Files variables), I tried "

file_get_contents('php://input')" with no success.
Do I need to use SCEP to have datas in this answer ?


I made a test with a custom mobileconfig script calling back the "http://whatismyudid.com/device/enroll" and the datas appears so i think my mobileconfig file is working fine.



Thanks

Posted on May 31, 2011 2:50 AM

Reply
7 replies

Jun 7, 2011 1:02 AM in response to vannerpham

Hello,


I made it working, here the infos that helped me :


The url for enrollment in the mobileconfig must be a php script "http://www.mydomain.com/enroll.php", event if you have a "invali profile", the script did called, you can check with


$data = file_get_contents('php://input');

file_put_contents("data.txt', $data);


in your script


My full script (the script who the url is in the mobileconfig):


There is no comment, sorry


$data = file_get_contents('php://input');


$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 = "";

$CHALLENGE = "";

$DEVICE_NAME = "";

$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 "CHALLENGE":

$CHALLENGE = $arrayCleaned[$iterator+1]['value'];

break;

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."&CHALLENGE=".$CHALLENGE."&DEVICE_NAME=".$DEVICE_NAME."&DEVICE_PR ODUCT=".$DEVICE_PRODUCT."&DEVICE_VERSION=".$DEVICE_VERSION;

// enrollment is a directory

header('Location: http://www.mydomain.com/AppStore/enrollment?'.$params);

Jun 7, 2011 3:18 PM in response to Kyle2011

Thanks Kyle2011,


So, I was able to record the XML POST data with this: file_put_contents("data.txt", $data);


I looks like this:


<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">

<dict>

<key>ICCID</key>

<string>8901 4104 2541 8901 7521</string>

<key>IMEI</key>

<string>01 266900 647352 2</string>

<key>PRODUCT</key>

<string>iPad2,2</string>

<key>UDID</key>

<string>591f30d41d0bd28597ad962491f1570ddbde4a8a</string>

<key>VERSION</key>

<string>8J2</string>

</dict>

</plist>


Do u know what we need to respond back to the device with so that we do not get the "Invalid Profile" error? I want to send user to webpage after we get the UDID.


Thanks.

I cannot get the informations of response from iPhone device in Phase2

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.