PHP Örnek Kod
<h3>XML Api Test</h3>
<h4>Eğer gelen cevap <b>10KB</b> geçerse <b>gzip</b> formatında gelir.</h4>
<?PHP
header("Content-Type:text/xml\n");
ini_set('default_charset', "ISO-8859-9");
if (!function_exists('gzdecode')) {
function gzdecode($DATA){
$GZ=tempnam('/tmp','ff');
@file_put_contents($GZ,$DATA);
ob_start();
readgzfile($GZ);
return ob_get_clean();
}
}
$XMLDATA =
"<KurumCELL>
<Oturum>
<Eposta>domain@domainadi.com</Eposta>
<Kullanici>kullaniciadi</Kullanici>
<Parola>sifre</Parola>
<KulID>4</KulID>
</Oturum>
<Islem>GirisYap</Islem>
</KurumCELL>";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.kurumcell.com/XML/xml.php');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, array("XML" => $XMLDATA));
$CIKTI = curl_exec($ch);
$CURL_INFO = curl_getinfo($ch);
curl_close($ch);
if ($CURL_INFO["http_code"] != 200){
die("Hata Oluştu: {$CURL_INFO["http_code"]}");
} else {
if ($CURL_INFO["content_type"] == "application/x-gzip"){
$CIKTI = gzdecode($CIKTI);
}
}
print $CIKTI;
?>