Created
August 31, 2011 07:19
-
-
Save hdemon/1182986 to your computer and use it in GitHub Desktop.
サイト用簡易tweet取得スクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
var hdemon = hdemon || {}; | |
hdemon.getTweet = { | |
get : function(json) { | |
var displayTweet = function(){ hdemon.getTweet.display(json); } | |
window.addEventListener("load", displayTweet); | |
}, | |
display : function(json) { | |
var wrapper = document.getElementById('tweet_wrapper'), | |
pTag, text, date; | |
json.forEach(function(obj){ | |
text = document.createTextNode(obj.text); | |
date = document.createTextNode(obj.created_at); | |
articleTag = document.createElement('article'); | |
articleTag.appendChild(text); | |
divTag = document.createElement('div'); | |
divTag.setAttribute('class', 'each_tweet'); | |
divTag.appendChild(articleTag); | |
wrapper.appendChild(divTag); | |
}); | |
} | |
}; | |
</script> | |
<!--- ↓を適宜変えること --> | |
<script type="application/javascript" src="http://api.twitter.com/1/statuses/user_timeline.json?screen_name=h_demon&count=3&callback=hdemon.getTweet.get"></script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment