所以。我正在尝试从列表提要中获取所有状态。更具体地说,这个https://dev.twitter.com/docs/api/1.1/get/lists/statuses
据我所知,它使用的是 OAuth 1.0a。我的问题是,我收到错误代码 32。
我正在使用以下代码:
<?php function buildBaseString($baseURI, $method, $params) {
$r = array();
ksort($params);
foreach($params as $key=>$value){
$r[] = "$key=" . rawurlencode($value);
}
return $method."&" . rawurlencode($baseURI) . '&' . rawurlencode(implode('&', $r));
}
function buildAuthorizationHeader($oauth) {
$r = 'Authorization: OAuth ';
$values = array();
foreach($oauth as $key=>$value)
$values[] = "$key=\"" . rawurlencode($value) . "\"";
$r .= implode(', ', $values);
return $r;
}
$url = "https://api.twitter.com/1.1/lists/statuses.json?slug=danskere-i-udlandet&owner_screen_name=d_fodbold&count=20";
$oauth_access_token = "29194047-Dzwsoo1KiQg69dbabt3nS2ezjjNzlbZdlKpLWsOOG";
$oauth_access_token_secret = "secret";
$consumer_key = "iCV8UbKjmq9LAw1XIvTQ";
$consumer_secret = "secret";
$oauth = array( 'oauth_consumer_key' => $consumer_key,
'oauth_nonce' => md5(microtime()),
'oauth_signature_method' => 'HMAC-SHA1',
'oauth_token' => $oauth_access_token,
'oauth_timestamp' => time(),
'oauth_version' => '1.0');
$base_info = buildBaseString($url, 'GET', $oauth);
$composite_key = rawurlencode($consumer_secret) . '&' . rawurlencode($oauth_access_token_secret);
$oauth_signature = base64_encode(hash_hmac('sha1', $base_info, $composite_key, true));
$oauth['oauth_signature'] = $oauth_signature;
// Make Requests
$header = array(buildAuthorizationHeader($oauth));
$options = array( CURLOPT_HTTPHEADER => $header,
//CURLOPT_POSTFIELDS => $postfields,
CURLOPT_HEADER => false,
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false);
$feed = curl_init();
curl_setopt_array($feed, $options);
$json = curl_exec($feed);
curl_close($feed);
$twitter_data = json_decode($json);
var_dump($twitter_data);
exit();?>
我不知道那里有什么问题。
我希望你们中的一些人可以。