前提:你的博客主机在国外!
说明: Twitter 的JavaScript调用, 如果浏览者没有翻墙,还是看不到内容的.我的博客主机刚好在国外.于是就想了这个办法
利用国外的服务器先读取出Twitter数据,再返回给浏览者
现在只想把内容显示出来.所有没有仔细去看 Twitter的API文档!
这里用的的接口函数是 http://twitter.com/statuses/user_timeline.xml?id=hzw513
函数是 :user_timeline ,后面xml是你需要的格式,其他的可用格式为 JSON、Atom 和 RSS
这个默认就返回用户名为 hzw513 的最新20条数据,
XML/HTML代码
- <?xml version="1.0" encoding="UTF-8"?>
- <statuses type="array">
- <status>
- <created_at>Wed Sep 09 05:36:42 +0000 2009</created_at>
- <id>3857923194</id>
- <text>twitter 读取数据国外服务器测试成功!</text>
- <source><a href="http://itweet.net/" rel="nofollow">iTweet</a></source>
- <truncated>false</truncated>
- <in_reply_to_status_id></in_reply_to_status_id>
- <in_reply_to_user_id></in_reply_to_user_id>
- <favorited>false</favorited>
- <in_reply_to_screen_name></in_reply_to_screen_name>
- <user>
- <id>68650526</id>
- <name>BB</name>
- <screen_name>hzw513</screen_name>
- <location></location>
- <description>What i am writting is not Twitter , but loneliness!</description>
- <profile_image_url>http://s.twimg.com/a/1252448032/images/default_profile_normal.png</profile_image_url>
- <url>http://www.hzw513.com</url>
- <protected>false</protected>
- <followers_count>2</followers_count>
- <profile_background_color>9ae4e8</profile_background_color>
- <profile_text_color>000000</profile_text_color>
- <profile_link_color>0000ff</profile_link_color>
- <profile_sidebar_fill_color>e0ff92</profile_sidebar_fill_color>
- <profile_sidebar_border_color>87bc44</profile_sidebar_border_color>
- <friends_count>0</friends_count>
- <created_at>Tue Aug 25 09:14:25 +0000 2009</created_at>
- <favourites_count>0</favourites_count>
- <utc_offset>28800</utc_offset>
- <time_zone>Beijing</time_zone>
- <profile_background_image_url>http://s.twimg.com/a/1252448032/images/themes/theme1/bg.gif</profile_background_image_url>
- <profile_background_tile>false</profile_background_tile>
- <statuses_count>19</statuses_count>
- <notifications></notifications>
- <verified>false</verified>
- <following></following>
- </user>
- </status>
- </statuses>
其他可选参数 :
since_id : 返回从某Id开始的数据
page : user_timeline 调用会返回最近的 20 个 tweet,你可以用page来控制页数
count : 指定返回的记录数
# ------------------------
我的思路就是 在服务器 用一个php文件通过以上方法去取得这些数据,然后经过处理之后显示给浏览者
具体的实现代码放和使用方法在附件了!

