Archive for August, 2009
集成Twitter到你的网站
如果你常用Twitter,想把tweets显示在你的网站或者Blog上,该怎么办?最简单的方式是用Twitter官方的一个JavaScript,可由于功夫网的缘故,在中国的用户无法使用它,如果你有自己的网站或者Blog,且位于墙外,下面的一段PHP代码可以达到你的目的:
// 读取Twitter的函数
function twitter_process($url)
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_USERAGENT, 'super_man');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$response = curl_exec($ch);
$response_info = curl_getinfo($ch);
curl_close($ch);
switch(intval($response_info['http_code']))
{
case 200:
$json = json_decode($response);
if ($json)
return $json;
return $response;
case 401:
default:
// NOOP
}
}
// 显示tweets在你的网站
$o = twitter_process("http://twitter.com/statuses/user_timeline/charry.json?count=5");
for ($i = 0; $i < count($o); $i++)
{
$item = $o[$i];
echo "<li>";
echo $item->{‘text’};
echo " – ".$item->{‘created_at’};
echo "</li>";
}
[ad]
身为屠刀,我如何放下屠刀
最近在看《家园》,一部描述地球,这个人类赖以生存的蓝色星球的纪录片。片中描述了人类文明的诞生与发展,导演用华丽的画面来控诉近几十年来人类对环境的破坏,而这些几乎不可逆转的破坏,使得我们的家园危机重重。
这是一部你值得关注的影片,据说北京最近有免费的公映,有机会的朋友可以去观摩一下,顺便给自己敲一个警钟。
有网友写影评如是:身为屠刀,我如何放下屠刀,请注意第一行字,别误解了作者。
另外:
我注意到一个和本片主题不太相关的内容:美国有农民300万,而生产的粮食可以养活20亿。不知道是否是真的如此,假如是:我们政府经常宣传的,7%的土地养活了22%的人口,实在是不值得一提。况且Google一下,似乎很多人对这个表述有所怀疑。
[ad]
Create your own public profile on Google
My Profile: http://www.google.com/profiles/charry.tar.gz
Bad news is: I can’t access this special link with Chrome, I got the following:
[ad]