/**
Uncommented the following line in php.ini: extension=php_curl.dll
Copied ssleay32.dll and libeay32.dll from C:\PHP to C:\WINNT\System32
Download curl.exe from this page e put it into c:\php\ext\
Added c:\php\ext\ to my system PATH environment variable.
regsvr32 c:\windows\system32\libeay32.dll
Verified that:
php.ini includes extension_dir="C:\php\ext" but not only "ext"
The directory C:\PHP\ext contains php_curl.dll
The only php.ini file on my system is in C:\PHP (i.e. especially that there is no C:\WINNT\php.ini)
The Apache httpd.conf file includes the line PHPIniDir "C:/PHP/"
*/
<?php
function post_xml($url, $xml) {
$arrayHeaders = Array(
"Content-Type: text/xml; charset=utf-8",
"SOAPAction: t\"urn:authenticate\"",
"Content-length: ". strlen($xml),
"Host: gsxws2.apple.com",
"User-Agent: gApache-HttpClient/4.1.1 (java 1.5)"
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $arrayHeaders);
//curl_setopt($ch, CURLOPT_USERPWD, 'myusername:mypassword');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
$result = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
echo $result;
echo $info;
echo htmlentities($result);
return $result;
}
$xml = "
<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:glob=\"http://gsxws.apple.com/elements/global\">
<soapenv:Header/>
<soapenv:Body>
<glob:Authenticate>
<AuthenticateRequest>
<userId>mgimondo@celltel.it</userId>
<password>\$Celltel10</password>
<languageCode>it</languageCode>
<userTimeZone>CEST</userTimeZone>
<serviceAccountNo>636264</serviceAccountNo>
</AuthenticateRequest>
</glob:Authenticate>
</soapenv:Body>
</soapenv:Envelope>";
$url = "https://gsxws2.apple.com/gsx-ws/services/emea/iphone?wsdl";
$result = post_xml($url, $xml);
echo "<pre>"; echo $result; "</pre>";
echo "<pre>"; print_r($result); echo "</pre>";
?>