我正在使用 twitter 数字。我的移动验证正常工作。但是当我调用 curl 时使用 auth 标头信息然后它不起作用。我的 curl 代码
$request=$_REQUEST['someData'];
function oauth_value($headersIndex = [])
{
if(empty($headersIndex)) return 'Invalid Index Number';
$value = explode('=', $headersIndex);
return str_replace('"', '', $value[1] );
}
$headersData = explode(',',$request['headers']);
$ch = curl_init();
$ch = curl_init($request['apiUrl']);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization' => 'OAuth oauth_consumer_key="'.oauth_value($headersData[0]).'",
oauth_nonce="'.oauth_value($headersData[1]).'",
oauth_signature="'.oauth_value($headersData[2]).'",
oauth_signature_method="HMAC-SHA1",
oauth_timestamp="'.oauth_value($headersData[4]).'",
oauth_token="'.oauth_value($headersData[5]).'",
oauth_version="'.oauth_value($headersData[6]).'"'
)
);
$resp = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
来自 $_REQUEST['someData'] 的示例信息;
Array
(
[apiUrl] => https://api.digits.com/1.1/sdk/account.json
[headers] =>
OAuth oauth_consumer_key="OybCXYoYTuS0Cw0usZYry6Nlj",
oauth_nonce="3942830480-TILitVHHZGmcczuuFj3nbJtnMm00DHvvgduawMHOybCXYoYTuS0Cw0usZYry6Nlj1445246231940",
oauth_signature="dXHcH%2FsLBIlYOVWBIhEBWSCMLJo%3D",
oauth_signature_method="HMAC-SHA1",
oauth_timestamp="1445246231",
oauth_token="3942830480-TILitVHHZGmcczuuFj3nbJtnMm00DHvvgduawMH",
oauth_version="1.0"
)
我现在能做什么?