Php ile TC Kimlik Doğrulama (SOAP)
$soapUrl = "https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx?WSDL";
$xml_post_string='<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<TCKimlikNoDogrula xmlns="http://tckimlik.nvi.gov.tr/WS">
<TCKimlikNo>11111111111</TCKimlikNo>
<Ad>AD</Ad>
<Soyad>SOYAD</Soyad>
<DogumYili>1950</DogumYili>
</TCKimlikNoDogrula>
</soap12:Body>
</soap12:Envelope>';
$headers = array(
"Content-type: application/soap+xml; charset=utf-8",
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache",
"SOAPAction: http://tempuri.org/writeXML",
"Content-length: ".strlen($xml_post_string),
); //SOAPAction: your op URL
$url = $soapUrl;
// PHP cURL for https connection with auth
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//curl_setopt($ch, CURLOPT_USERPWD, $soapUser.":".$soapPassword); // username and password - declared at the top of the doc
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); // the SOAP request
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// converting
$response= curl_exec($ch);
curl_close($ch);
// print_r($response);
$xml = preg_replace("/(<\/?)(\w+):([^>]*>)/", "$1$2$3", $response);
$xml = simplexml_load_string($xml);
$json = json_encode($xml);
// var_dump($json);
$responseArray = json_decode($json,true);
return $responseArray["soapBody"]["TCKimlikNoDogrulaResponse"]["TCKimlikNoDogrulaResult"];
Hiç yorum yok :
Yorum Gönder