Created
May 12, 2017 22:14
-
-
Save isubas/243b814beacbf53720beda86dea001b6 to your computer and use it in GitHub Desktop.
Google Spreadsheet Üzerinden T.C. Kimlik No Doğrulama
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String.prototype.turkishUpperCase = function () { | |
return this.replace(/ğ/g, 'Ğ') | |
.replace(/ü/g, 'Ü') | |
.replace(/ş/g, 'Ş') | |
.replace(/ı/g, 'I') | |
.replace(/i/g, 'İ') | |
.replace(/ö/g, 'Ö') | |
.replace(/ç/g, 'Ç') | |
.toUpperCase(); | |
}; | |
function tcKimlikDogrulama(tcKimlikNo, ad, soyad, dogumYili) { | |
var requestSoapXml = | |
'<?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.turkishUpperCase() + '</Ad>' + | |
'<Soyad>' + soyad.turkishUpperCase() + '</Soyad>' + | |
'<DogumYili>' + dogumYili + '</DogumYili>' + | |
'</TCKimlikNoDogrula>'+ | |
'</soap:Body>'+ | |
'</soap:Envelope>' | |
var options = { | |
'method': 'post', | |
'payload': requestSoapXml, | |
'contentType': 'text/xml; charset=utf-8' | |
}; | |
try { | |
var response = UrlFetchApp.fetch( | |
'https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx', options | |
); | |
/* response | |
<?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> | |
<TCKimlikNoDogrulaResponse xmlns="http://tckimlik.nvi.gov.tr/WS"> | |
<TCKimlikNoDogrulaResult>boolean</TCKimlikNoDogrulaResult> | |
</TCKimlikNoDogrulaResponse> | |
</soap:Body> | |
</soap:Envelope> | |
*/ | |
var status = XmlService.parse(response.getContentText()) | |
.getRootElement() | |
.getChildren()[0] | |
.getChildren()[0] | |
.getChildren()[0] | |
.getValue() | |
} catch(error){ | |
var status = 'false' | |
}; | |
var ui = SpreadsheetApp.getUi(); | |
ui.alert(status == 'true' ? 'T.C. Kimlik No Doğrulandı' : 'T.C. Kimlik No Doğrulanamadı') | |
//Logger.log(response.getContentText()) | |
} | |
function main(){ | |
tcKimlikDogrulama(11223344556, 'Foo', 'Bar', 2017) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment