· 9 years ago · Nov 09, 2016, 03:34 PM
1$signature = ??????
2 $curl = curl_init();
3 curl_setopt($curl, CURLOPT_URL, 'https://api.digits.com/1.1/sdk/account.json');
4 curl_setopt($curl, CURLOPT_HTTPHEADER, array(
5 'Content-length: 0',
6 'Content-type: application/json',
7 'Authorization: ' . 'OAuth oauth_nonce="39914766530163254991478493084", oauth_timestamp="1478493084", oauth_version="1.0", oauth_signature_method="HMAC-SHA1", oauth_consumer_key="' . $consumerKey . '", oauth_token="' . $oauthToken . '", oauth_signature="'.$signature.'"',
8 ));
9 curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
10 $result = curl_exec($curl);
11 $info = curl_getinfo($curl);
12 if ($info['http_code'] == 200) {
13 $r = json_decode($result);
14// var_dump($r->phone_number);
15// die();
16 if (strval($r->phone_number) == strval($phone)) {
17 // phone is equal, validate the user
18 curl_close($curl);
19 return true;
20 } else {
21 // phone is not equal
22 curl_close($curl);
23 return false;
24 }
25
26 } else {
27 // unable to auth the user
28 curl_close($curl);
29 return false;
30 }