<?php
function tcKimlikDogrula($tcKimlikNo, $ad, $soyad, $dogumYili) {
$soapUrl = "https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx";
$soapAction = "http://tckimlik.nvi.gov.tr/WS/TCKimlikNoDogrula";
$xml_post_string = '<?xml version="1.0" encoding="utf-8"?>' .
'<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">' .
'<soap:Body>' .
'<TCKimlikNoDogrula xmlns="http://tckimlik.nvi.gov.tr/WS">' .
'<TCKimlikNo>' . $tcKimlikNo . '</TCKimlikNo>' .
'<Ad>' . $ad . '</Ad>' .
'<Soyad>' . $soyad . '</Soyad>' .
'<DogumYili>' . $dogumYili . '</DogumYili>' .
'</TCKimlikNoDogrula>' .
'</soap:Body>' .
'</soap:Envelope>';
$headers = array(
"Content-type: text/xml;charset=\"utf-8\"",
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache",
"SOAPAction: $soapAction",
"Content-length: " . strlen($xml_post_string),
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $soapUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
curl_close($ch);
$doc = new DOMDocument();
$doc->loadXML($response);
$result = $doc->getElementsByTagName("TCKimlikNoDogrulaResult")->item(0)->nodeValue;
return $result == "true";
}
$tcKimlikNo = "";
$ad = "";
$soyad = "";
$dogumYili = ;
$result = tcKimlikDogrula($tcKimlikNo, $ad, $soyad, $dogumYili);
if ($result) {
//KİMLİK BİLGİLERİ DOĞRU İSE
echo "true";
} else {
//KİMLİK BİLGİLERİ DOĞRU DEĞİL İSE
}
?>