我有这段工作代码(PHP)。我遇到的问题是 strftime('%e %B',strtotime($time)); 部分(位于块的末尾)。它什么也没返回..我做错了什么?也许是语法错误?
<?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)); //return complete base string
}
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/statuses/user_timeline.json";
$oauth_access_token = "XXXXXX";
$oauth_access_token_secret = "XXXXXX";
$consumer_key = "XXXXXX";
$consumer_secret = "XXXXXX";
$oauth = array( 'oauth_consumer_key' => $consumer_key,
'oauth_nonce' => time(),
'oauth_signature_method' => 'HMAC-SHA1',
'oauth_token' => $oauth_access_token,
'oauth_timestamp' => time(),
'count' => 6,
'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;
$header = array(buildAuthorizationHeader($oauth), 'Expect:');
$options = array( CURLOPT_HTTPHEADER => $header,
CURLOPT_HEADER => false,
CURLOPT_URL => $url . '?count=6',
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);
echo "
<ul style='color:#6E6E6E'>";
foreach ($twitter_data as $tweet)
{
if (!empty($tweet)) {
$text = $tweet->text;
}
if (!empty($tweet)) {
$id = $tweet->id;
}
if (!empty($tweet)) {
$time = $tweet->created_at;
}
if (!empty($tweet)) {
$username = $tweet->user->name;
}
echo '<li>';
echo $text . "<br><a href=\"http://twitter.com/";
echo $username ;
echo '/status/';
echo $id ;
echo '"><small>';
strftime('%e %B',strtotime($time));
' </small></a> - <a href="http://twitter.com/intent/tweet?in_reply_to=';
echo $id;
echo '"><small>rispondi</small></a> - <a href="http://twitter.com/intent/retweet?tweet_id=';
echo $id;
echo '"><small>retweet</small></a> - <a href="http://twitter.com/intent/favorite?tweet_id=';
echo $id;
echo '"><small>preferito</small></a></li>';
}
echo '
</ul>';
?>