<head> 부분에....
<script type="text/javascript">
var t_username = 'OnnuriPoint5'; // username 대신 여러분의 아이디를 넣으세요
var t_count = 1; // 한번에 나타낼 갯수를 적어 넣으세요
function throwHTML (obj){
var statusHTML = [];
for (var i=0; i<obj.length; i++){
var username = obj[i].from_user;
var status = obj[i].text.replace(/((https?|s?ftp|ssh)\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!])/g, function(url) {
return '<a href="'+url+'" target="_blank">'+url+'</a>';
}).replace(/\B@([_a-z0-9]+)/ig, function(reply) {
return reply.charAt(0)+'<a href="http://twitter.com/ '+reply.substring(1)+'" target="_blank">'+reply.substring(1)+'</a>';
}).replace(/\B#([_a-z0-9]+)/ig, function(reply) {
return reply.charAt(0)+'<a href="http://twitter.com/search?q=%23 '+reply.substring(1)+'" target="_blank">'+reply.substring(1)+'</a>';
});
statusHTML.push('<li><span>'+status+'</span> <a class="twt_time" href="http://twitter.com/ '+t_username+'/statuses/'+obj[i].id_str+'" target="_blank">'+relative_time(obj[i].created_at)+'</a> <span class="twt_slash">/</span> <a class="twt_reply" href="http://twitter.com/?status=@ '+t_username+'%20&in_reply_to_status_id='+obj[i].id_str+'&in_reply_to='+t_username+'" target="_blank">reply</a></li>');
}
return statusHTML.join('');
}
function twitterCallback(twitters) {
document.getElementById('twitter_update_list').innerHTML = throwHTML (twitters);
}
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 'yesterday';
} else {
return (parseInt(delta / 86400)).toString() + ' days ago';
}
}
function getRecentTweets(){
var script = document.createElement('script');
var head = document.getElementsByTagName('head')[0];
script.type = 'text/javascript';
script.src = 'http://api.twitter.com/1/statuses/user_timeline.json?screen_name='+t_username+'&include_rts=true&count='+t_count+'&callback=twitterCallback';
head.insertBefore(script, head.firstChild);
}
if (window.addEventListener) {
window.addEventListener("load", getRecentTweets, false);
} else if (window.attachEvent) {
window.attachEvent("onload",getRecentTweets);
} else {
window.onload=getRecentTweets;
}
</script>
<td>
<div id="twitter_update_list" class=conts></div><td>
</td>
'개발도구 > PHP,ASP,JSP,SCRIPT' 카테고리의 다른 글
[php] 스마트 폰 가로지원 환경설정 - Detecting Smart Phone Screen Orientation in PHP & Javascript (0) | 2012.12.06 |
---|---|
[php] PHP MVC - codeigniter (1) | 2012.12.05 |
[PHP] 예약어 - 실제 코드에서 사용중인 중요소스 (0) | 2012.02.01 |
[php] php 공백제거 와 urlencode 유니코드 (0) | 2012.02.01 |
[php] usr/local/apache2/conf/php.ini register_globals (0) | 2012.01.30 |