Hızlı Başlangıç
İlk doğrulama oturumunuzu açın ve sonucu alın.
Bu sayfanın sonunda çalışan bir doğrulama akışınız olacak. Yaklaşık 10 dakika sürer.
Gereken#
- Bir API anahtarı (
sk_test_…yeterli) curlveya herhangi bir HTTP istemcisi- Telefonunuzda GlobalTrustID uygulaması (QR'ı okutacak taraf)
1. Oturum açın#
curl -X POST https://api.globaltrust.id/v1/verification/session \
-H "Authorization: Bearer sk_test_a1b2c3..." \
-H "Content-Type: application/json" \
-d '{
"scope": ["identity.first_name", "identity.last_name", "identity.birth_date"]
}'Yanıt:
{
"status": true,
"data": {
"session_id": "01J8ZQ4X7K9M2N3P4Q5R6S7T8U",
"qr": "https://api.globaltrust.id/v1/verification/session/01J8ZQ.../qr.svg",
"scope": ["identity.first_name", "identity.last_name", "identity.birth_date"],
"status": "waiting",
"expires_at": "2026-09-01T12:30:00Z"
},
"error_code": 0,
"error_message": null
}Bütün yanıtlar bu zarf içinde döner; işinize yarayan içerik data alanındadır. Ayrıntı için Hata Kodları.
2. QR kodu gösterin#
qr alanındaki adresi bir <img> içinde gösterin:
<img src="https://api.globaltrust.id/v1/verification/session/01J8ZQ.../qr.svg"
alt="Doğrulamak için okutun" width="240" height="240">Kullanıcı bunu GlobalTrustID uygulamasıyla okutur, hangi alanları paylaşacağını görür ve onaylar.
3. Sonucu alın#
En basit yol oturumu sorgulamaktır:
curl https://api.globaltrust.id/v1/verification/session/01J8ZQ4X7K9M2N3P4Q5R6S7T8U \
-H "Authorization: Bearer sk_test_a1b2c3..."Kullanıcı onayladıysa:
{
"status": true,
"data": {
"session_id": "01J8ZQ4X7K9M2N3P4Q5R6S7T8U",
"status": "approved",
"scope": ["identity.first_name", "identity.last_name", "identity.birth_date"],
"identity": {
"identity.first_name": "Ayşe",
"identity.last_name": "Yılmaz",
"identity.birth_date": "1990-04-17"
}
},
"error_code": 0,
"error_message": null
}PHP ile aynı akış#
Yukarıdaki iki adımın PHP karşılığı. Tüm yanıtlar aynı zarf içinde geldiği için tek bir yardımcı yeterli.
<?php
function gtiIstek(string $yol, ?array $govde = null): array
{
$ch = curl_init('https://api.globaltrust.id/v1' . $yol);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 15,
CURLOPT_HTTPHEADER => [
// Gizli anahtar yalnızca sunucuda. Koda gömmeyin.
'Authorization: Bearer ' . getenv('GTI_SECRET_KEY'),
'Content-Type: application/json',
],
]);
if ($govde !== null) {
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($govde, JSON_UNESCAPED_UNICODE));
}
$yanit = curl_exec($ch);
if ($yanit === false) {
throw new RuntimeException('GlobalTrustID: ' . curl_error($ch));
}
curl_close($ch);
$zarf = json_decode($yanit, true);
// Hata kontrolü error_code üzerinden: error_message metni değişebilir,
// kod değişmez. Bkz. Hata Kodları.
if (!($zarf['status'] ?? false)) {
throw new RuntimeException(
'GlobalTrustID hata ' . ($zarf['error_code'] ?? '?') . ': ' .
($zarf['error_message'] ?? 'bilinmeyen')
);
}
return $zarf['data'];
}1. Oturum aç
<?php
$oturum = gtiIstek('/verification/session', [
'scope' => ['identity.first_name', 'identity.last_name', 'identity.birth_date'],
'webhook_url' => 'https://sizin-siteniz.com/gti/webhook',
]);
// Kendi tarafınızda saklayın: sonucu bu kimlikle eşleştireceksiniz.
$sessionId = $oturum['session_id'];2. QR'ı göster
<img src="<?= htmlspecialchars($oturum['qr'], ENT_QUOTES) ?>"
alt="Doğrulamak için okutun" width="240" height="240">3. Sonucu oku
<?php
$sonuc = gtiIstek('/verification/session/' . rawurlencode($sessionId));
if ($sonuc['status'] === 'approved') {
$ad = $sonuc['identity']['identity.first_name'];
$soyad = $sonuc['identity']['identity.last_name'];
$dogum = $sonuc['identity']['identity.birth_date']; // YYYY-MM-DD
}Sürekli sorgulamayın#
Yukarıdaki örnek denemek için uygundur ama üretimde kullanıcıyı bekletirken döngüyle sorgu atmayın. İki daha iyi yol var:
- Webhook — sonuç hazır olduğunda size biz haber veririz. Bkz. Webhooks.
- WebSocket — tarayıcıda anlık güncelleme için. Bkz. Doğrulama Akışı.
Sırada ne var#
- Doğrulama Akışı — oturum durumları ve uçtan uca entegrasyon
- Webhooks — sonucu anında almak
- Hata Kodları — bir şey ters gittiğinde