-
Notifications
You must be signed in to change notification settings - Fork 0
/
verify.php
53 lines (37 loc) · 1.89 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
<?php
error_reporting(0);
define( "FB_ACCOUNT_KIT_APP_ID", "392736194511520" );
define( "FB_ACCOUNT_KIT_APP_SECRET", "ba6951b1bc50bcb4581e55fba0750127" );
$code = $_POST['code'];
$csrf = $_POST['csrf'];
$auth = file_get_contents( 'https://graph.accountkit.com/v1.1/access_token?grant_type=authorization_code&code='. $code .'&access_token=AA|'. FB_ACCOUNT_KIT_APP_ID .'|'. FB_ACCOUNT_KIT_APP_SECRET );
$access = json_decode( $auth, true );
if( empty( $access ) || !isset( $access['access_token'] ) ){
return array( "status" => 2, "message" => "Unable to verify the phone number." );
}
//App scret proof key Ref : https://developers.facebook.com/docs/graph-api/securing-requests
$appsecret_proof= hash_hmac( 'sha256', $access['access_token'], FB_ACCOUNT_KIT_APP_SECRET );
//echo 'https://graph.accountkit.com/v1.1/me/?access_token='. $access['access_token'];
$ch = curl_init();
// Set query data here with the URL
curl_setopt($ch, CURLOPT_URL, 'https://graph.accountkit.com/v1.1/me/?access_token='. $access['access_token'].'&appsecret_proof='. $appsecret_proof );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch, CURLOPT_TIMEOUT, '4');
$resp = trim(curl_exec($ch));
curl_close($ch);
$info = json_decode( $resp, true );
if( empty( $info ) || !isset( $info['phone'] ) || isset( $info['error'] ) ){
return array( "status" => 2, "message" => "Unable to verify the phone number." );
}
$phoneNumber = $info['phone']['national_number'];
echo json_encode( $info );
/*
$user = $this->db->query( "SELECT * FROM user WHERE phone_number = '". $phoneNumber ."'" )->result_array();
if( !empty( $user ) ){
//Create session
return array( "status" => "01", "message" => "Login success", "token" => $jwt );
}else{
return array( "status" => "02", "message" => "Phonenumber not registered with us." );
}*/
?>