-
Notifications
You must be signed in to change notification settings - Fork 0
/
verify.php
73 lines (59 loc) · 1.8 KB
/
verify.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
// Token
$ch = curl_init();
$url = "https://www.devkng.com/kyc/token.php";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$resp = curl_exec($ch);
if($e = curl_error($ch)) {
echo $e;
} else {
$data = json_decode($resp,true);
$access_token = $data['access_token'];
}
curl_close($ch);
// Verify
$headers[]='accept: application/json';
$headers[]='x-api-key: key_live_5mLgQntwj9QnmRc3Vn7XBPJ2Bqcw';
$headers[]='x-api-version: 1.0';
// Check if the 'aadhar_no' parameter is set in the POST request
if(isset($_POST['aadhar_no'])) {
// Get the value of 'aadhar_no' from the POST request
$aadhar_no = $_POST['aadhar_no'];
// API endpoint URL
$url = 'https://api.sandbox.co.in/kyc/aadhaar/okyc/otp';
// Request body
$data = json_encode(array(
'aadhaar_number' => $aadhar_no
));
// Request headers
$headers = array(
'Authorization: ' . $access_token,
'Accept: application/json',
'Content-Type: application/json',
'x-api-key: key_live_5mLgQntwj9QnW9XmRWc3Vn7XBPJ2Bqcw',
'x-api-version: 1.0'
);
// Initialize cURL session
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// Execute cURL request
$response = curl_exec($ch);
// Check for errors
if(curl_errno($ch)){
echo 'Error: ' . curl_error($ch);
}
// Close cURL session
curl_close($ch);
// Output the response
echo $response;
} else {
// If 'aadhar_no' parameter is not set, return an error message
echo "Error: 'aadhar_no' parameter is not set.";
}
?>