我一直在尋求在SF上的OAuth站點&上創建簽名,但是我創建了我的簽名我總是得到相同的錯誤,任何想法我做錯了這裏?無法驗證oauth簽名和令牌 - 生成OAuth令牌的問題
Error: Failed to validate oauth signature and token
我有一個工作程序舊其餘API,所以我知道我的問題是不是與我的應用程序或服務器等
<?php
function Post_Data($url,$data,$header){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
// Get OAuth Token
$consumer_key = "hidden";
$consumer_secret = "hidden";
$request_url = "http://api.twitter.com/oauth/request_token";
$callback = "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
$nonce = md5(time());
$timestamp = time();
$data = array(
"oauth_callback" => $callback,
"oauth_consumer_key" => $consumer_key,
"oauth_nonce" => $nonce,
"oauth_signature_method" => "HMAC-SHA1",
"oauth_timestamp" => $timestamp,
"oauth_version" => "1.0"
);
$post_string = '';
foreach($data as $key => $value){
$post_string .= $key.'='.($value).'&';
}
$post_string = rtrim($post_string, '&');
$base_string = 'GET&'.urlencode($request_url).'&'.urlencode($post_string);
$data["oauth_signature"] = base64_encode(hash_hmac('sha1', $base_string, $consumer_secret, true));
$header = array("Expect:");
$content = Post_Data($request_url,$data,$header);
print_r($content);
?>
不幸的是不是這個問題,我花了,而從美洲/歐洲改變時區與date_default_timezone_set與錯誤消息沒有變化返回。 – Chris 2011-03-28 21:57:43