🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: cn.comp.hacker
Article #13365

支持所有BLOG的Twitter的显示更新插件代码

#13365
From: RSS Feed For GFW Blog
Date: Wed, 30 Sep 2009 05:45
68 lines
6680 bytes
来源:[广陵散 `s 博客 lizhenglin.com][1]


请将代码中两处mickeywaley改成你自己的Twitter ID

添加代码到侧边栏目就OK了

演示效果见我blog右侧


代码如下:


<div id="twitter_div">


<h2 class="sidebar-title">Twitter的更新</h2>


<ul id="twitter_update_list"></ul>


<a href="[http://twitese.appspot.com/info?id=mickeywaley][2]" id="twitter-link" style="display:block;text-align:right;">跟随我的Twitter</a>


</div>


<p>


<script type="text/javascript" src="[http://www.lizhenglin.com/Twitter/Twitter.js][3]"></script>


<script type="text/javascript"
src="[http://nest.onedd.net/api/statuses/user_timeline/mickeywaley.json?callback=twitterCallback2&amp;count=10][4]″></script>


提供几个可用的Twitter API


这些API失效后可以自己在GOOGLE免费架设,


[http://nest.onedd.net/api/][5]

[http://t.zhe.la/api/][6]


具体方法请搜索BLOG:关键词:twitter


简单说明下:


[http://twitese.appspot.com/info?id=][7]


可以替换成[http://nest.onedd.net/api/][5]


[http://nest.onedd.net/api/][5]失效后可以替换成[http://t.zhe.la/api/][6]


其中

[http://www.lizhenglin.com/Twitter/Twitter.js][3]

的JS代码可以下载后放自己空间


代码如下:


function twitterCallback2(twitters) {


var statusHTML = [];


for (var i=0; i<twitters.length; i++){


var username = twitters[i].user.screen_name;


var status = twitters[i].text.replace(/((https?|s?ftp|ssh)\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!])/g, function(url) {


return '<a href="'+url+'">'+url+'</a>';


}).replace(/\B@([_a-z0-9]+)/ig, function(reply) {


return reply.charAt(0)+'<a href="[http://twitese.appspot.com/info?id=][7]'+reply.substring(1)+'">'+reply.substring(1)+'</a>';


});


statusHTML.push('<li><span>'+status+'</span> <a style="font-size:85%" href="[https://go-
west.appspot.com/twitter.com/][8]'+username+'/statuses/'+twitters[i].id+'">'+relative_time(twitters[i].created_at)+'</a></li>');


}


document.getElementById('twitter_update_list').innerHTML = statusHTML.join(");


}


function relative_time(time_value) {


var values = time_value.split(" ");


time_value = values[1] + " " + values[2] + ", " + values[5] + " " + values[3];


var parsed_date = Date.parse(time_value);


var relative_to = (arguments.length > 1) ? arguments[1] : new Date();


var delta = parseInt((relative_to.getTime() � parsed_date) / 1000);


delta = delta + (relative_to.getTimezoneOffset() * 60);


if (delta < 60) {


return 'less than a minute ago';


} else if(delta < 120) {


return 'about a minute ago';


} else if(delta < (60*60)) {


return (parseInt(delta / 60)).toString() + ' minutes ago';


} else if(delta < (120*60)) {


return 'about an hour ago';


} else if(delta < (24*60*60)) {


return 'about ' + (parseInt(delta / 3600)).toString() + ' hours ago';


} else if(delta < (48*60*60)) {


return '1 day ago';


} else {


return (parseInt(delta / 86400)).toString() + ' days ago';


}


}



   [1]: http://www.lizhenglin.com/blog/?p=643

   [2]: http://twitese.appspot.com/info?id=mickeywaley

   [3]: http://www.lizhenglin.com/Twitter/Twitter.js

   [4]: http://nest.onedd.net/api/statuses/user_timeline/mickeywaley.json?callback=twitterCallback2&count=10

   [5]: http://nest.onedd.net/api/

   [6]: http://t.zhe.la/api/

   [7]: http://twitese.appspot.com/info?id=

   [8]: https://go-west.appspot.com/twitter.com/

敬请订阅我们:http://feeds2.feedburner.com/chinagfwblog,在twitter跟随我们:http://twitter.com/cdt。翻墙工具介绍和下载:http://www.sesawe.org/和http://www.sesawwe.net/。![][9]

   [9]: https://blogger.googleusercontent.com/tracker/5500297126185736776-846889726630771630?l=www.chinagfw.org

Contentes HTML URL: http://www.chinagfw.org/2009/09/blogtwitter_29.html

Send By Feed RSS2eMail BOT V2.65
Admin By Liuxing99
Technical Details
Message-ID: <4ac34016@news.liuxing99.3322.org>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nx02.iad01.newshosting.com!newshosting.com!newsfeed2.ip.tiscali.net!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!61.160.212.82.MISMATCH!www.shinco.com!news.liuxing99.3322.org!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 85629cb6ee,2204089c2e949f27,start
X-Google-Attributes: gid85629cb6ee,public,usenet
X-Google-NewGroupId: yes
X-Google-Language: Chinese,UTF8
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nx02.iad01.newshosting.com!newshosting.com!newsfeed2.ip.tiscali.net!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!61.160.212.82.MISMATCH!www.shinco.com!news.liuxing99.3322.org!not-for-mail
From: RSS Feed For GFW Blog <gfwblog-list@szb66.vicp.net>
Newsgroups: cn.comp.hacker
Subject:  支持所有BLOG的Twitter的显示更新插件代码
Date: Wed, 30 Sep 2009 05:45:00 -0000
Organization: A poorly-installed InterNetNews site
Lines: 68
Message-ID: <4ac34016@news.liuxing99.3322.org>
NNTP-Posting-Host: 58.209.241.41
Mime-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64
X-Trace: www.shinco.com 1254309965 31216 58.209.241.41 (30 Sep 2009 11:26:05 GMT)
X-Complaints-To: news@www.shinco.com
NNTP-Posting-Date: Wed, 30 Sep 2009 11:26:05 +0000 (UTC)
Received-Path: <gfwblog-list@szb66.vicp.net>
X-Feed-By: news.liuxing99.3322.org
User-Agent: Feed RSS2eMail BOT V2.65
X-Gateway-Administrator: bianlule@bianlule.3322.org
X-Gateway-From: dnews-gateway@news.liuxing99.3322.org