Skip to content

Instantly share code, notes, and snippets.

@hdemon
Created August 31, 2011 07:19
Show Gist options
  • Save hdemon/1182986 to your computer and use it in GitHub Desktop.
Save hdemon/1182986 to your computer and use it in GitHub Desktop.
サイト用簡易tweet取得スクリプト
<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