実行結果
「cocoism」のTwitterのつぶやき新着5件
「cocoism」のDeliciousのブックマーク新着5件
設置サンプルのソース
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="ja" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="imagetoolbar" content="no" />
<title>Unobtrusive Twitter and Delicious feeds using MooTools | 設置サンプル</title>
<link rel="stylesheet" type="text/css" href="/content/lib/global.css" />
<!-- JS -->
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">google.load("mootools", "1.2.2");</script>
<script type="text/javascript" src="/content/lib/mootools/mootools-1.2.2.2-more.more.log.jsonp.js"></script>
<script type="text/javascript">
window.addEvent('domready', function() {
// Twitter JSONP request
var myTwitterRequest = new Request.JSONP({
url: 'http://twitter.com/status/user_timeline/cocoism.json',
data: {
count: '5'
},
noCache: true,
onComplete: function(myTweets) {
var el = $('twitter-post'); // 直した
el.empty();
myTweets.each(function(tweet) {
var myElement = new Element('li',{
html: '<p>' + tweet.text + '</p>'
}).injectInside(el); // 直した
});
}
}).send();
// Delicious JSONP request
var myDeliciousRequest = new Request.JSONP({
url: 'http://feeds.delicious.com/v2/json/cocoism',
data: {
count: '5'
},
noCache: true,
onComplete: function(myBookmarks) {
var el = $('delicious-links'); // 直した
el.empty();
myBookmarks.each(function(bookmark) {
var myElement = new Element('li',{
html: '<a href="' + bookmark.u + '">' + bookmark.d + '</a><p>' + bookmark.n + '</p>'
}).injectInside(el); // 直した
});
}
}).send();
});
</script>
<style type="text/css">
ul,li {
margin:0 0 10px 0; padding:0;
list-style:none;
}
#twitter-post li {
background:transparent url(/content/img/sbm/twitter_16.png) no-repeat 0 0;
padding-left:20px;
line-height:16px;
}
#delicious-links li {
background:transparent url(/content/img/sbm/delicious_16.png) no-repeat 0 0;
padding-left:20px;
line-height:16px;
}
</style>
<link rel="stylesheet" type="text/css" href="/common/css/example.css"></head>
<body id='example3' class='example'><div class="ads" style="margin:32px auto;text-align:center;"></div><h1 class='h'><a href='/'>PHP & JavaScript Room</a> :: 設置サンプル</h1>
<h3 class='h'>実行結果</h3>
<div id="wrap">
<h1><a href='http://www.alexgdesign.co.uk/articles/unobtrusive-twitter-delicious-mootools/index.html'>Unobtrusive Twitter and Delicious feeds using MooTools</a> | 設置サンプル</h1>
<!-- CODE -->
<h2>「cocoism」のTwitterのつぶやき新着5件</h2>
<ul id="twitter-post">
<li><a href="http://twitter.com/cocoism">View my Twitter updates</a></li>
</ul>
<h2>「cocoism」のDeliciousのブックマーク新着5件</h2>
<ul id="delicious-links">
<li><a href="http://twitter.com/cocoism">View my Delicious bookmarks</a></li>
</ul>
<!-- / CODE -->
</div>
</body>
</html>