function tcno_dogrula($bilgiler){ $gonder = '<?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>'.$bilgiler["tcno"].'</TCKimlikNo> <Ad>'.$bilgiler["isim"].'</Ad> <Soyad>'.$bilgiler["soyisim"].'</Soyad> <DogumYili>'.$bilgiler["dogumyili"].'</DogumYili> </TCKimlikNoDogrula> </soap:Body> </soap:Envelope>'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx" ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true ); curl_setopt($ch, CURLOPT_POST, true ); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_POSTFIELDS, $gonder); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'POST /Service/KPSPublic.asmx HTTP/1.1', 'Host: tckimlik.nvi.gov.tr', 'Content-Type: text/xml; charset=utf-8', 'SOAPAction: "http://tckimlik.nvi.gov.tr/WS/TCKimlikNoDogrula"', 'Content-Length: '.strlen($gonder) )); $gelen = curl_exec($ch); curl_close($ch); return strip_tags($gelen); }$bilgiler = array( "isim" => "ALİ ATA", "soyisim" => "BAK", "dogumyili" => "xxxx", "tcno" => "xxxxx" );
$sonuc = tcno_dogrula($bilgiler); if($sonuc=="true"){ echo "Doğrulama başarılı"; }else{ echo "Doğrulama başarısız"; }
Daha temiz olması açısından sizin kodların üzerinden ilerleme yaparak POSTMAN üzerinden kontrol ettiğimde gayet güzel ve başarılı sonuç elde ettim aşağıda fonksiyonları ve response görüntüsünü paylaşıyorum kullanmak isteyen arkadaşlar olursa gayet sağlıklı şekilde çalışıyor kontrol edebilirsiniz.
<?php
function NVITCSorgula($bilgiler = array()) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'<?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>'.$bilgiler['TCKimlikNo'].'</TCKimlikNo>
<Ad>'.$bilgiler['Ad'].'</Ad>
<Soyad>'.$bilgiler['Soyad'].'</Soyad>
<DogumYili>'.$bilgiler['DogumYili'].'</DogumYili>
</TCKimlikNoDogrula>
</soap:Body>
</soap:Envelope>',
CURLOPT_HTTPHEADER => array(
'POST: /Service/KPSPublic.asmx HTTP/1.1',
'Host: tckimlik.nvi.gov.tr',
'Content-Type: text/xml; charset=utf-8',
'SOAPAction: "http://tckimlik.nvi.gov.tr/WS/TCKimlikNoDogrula"',
'Cookie: TS0193588c=01e4b30442ae308bf9bb635dc7895298e8f2d382b1f484a1209cb70726a4888c12c705b7ed57df13477e3ae27f77feafa66b531bab'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
}<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<TCKimlikNoDogrulaResponse xmlns="http://tckimlik.nvi.gov.tr/WS">
<TCKimlikNoDogrulaResult>true</TCKimlikNoDogrulaResult>
</TCKimlikNoDogrulaResponse>
</soap:Body>
</soap:Envelope>