0
我正在使用此代碼來驗證用戶的Twitter帳戶。如何驗證Oauth v1和PHP
$signature = ??????
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://api.digits.com/1.1/sdk/account.json');
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-length: 0',
'Content-type: application/json',
'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.'"',
));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
$result = curl_exec($curl);
$info = curl_getinfo($curl);
if ($info['http_code'] == 200) {
$r = json_decode($result);
// var_dump($r->phone_number);
// die();
if (strval($r->phone_number) == strval($phone)) {
// phone is equal, validate the user
curl_close($curl);
return true;
} else {
// phone is not equal
curl_close($curl);
return false;
}
} else {
// unable to auth the user
curl_close($curl);
return false;
}
但我不知道應該用什麼來代替$簽名。我怎樣才能生成$簽名。
問候