==mixi アプリ Twitter 検索==
[[mixi アプリ]]
===Twitter の 検索を行うサンプル===
*[http://code.google.com/intl/ja/apis/gadgets/docs/remote-content.html#Fetch_JSON Google Gadgets API JSON利用サンプル]
<<?xml version="1.0" encoding="UTF-8" ?> > <<Module>> <<ModulePrefs title="twitter search sample">> <<Require feature="opensocial-0.8"/>> <</ModulePrefs> > <<Content type="html">> <<![CDATA[ <<style type="text/css">>
a:active, a:hover, .b:active, .link:active {
color:#AAAAAA;
text-decoration:none;
}
<</style> > <<script type="text/javascript">>
/**
* mixi アプリ : Twitterの検索を行う
var next_page = jsondata['next_page'];
if (next_page) {
html += "<<a href='javascript:search_twitter(\"" + next_page + "\");'>>next page<</a>>"; html += "<<br/>>";
}
var results = jsondata['results'];
html +="<<table border='0'>>"; for (var i=0; i<<results.length; i++) {
var result = results[i];
html += "<<tr style='font-size:small;'>>"; html += "<<td>>"; html += "<<a href='http://twitter.com/" + result['from_user'] + "' target='_blank'>>"; html += "<<img src='" + result['profile_image_url'] + "' border='none'/>>"; html += "<</a>>"; html += "<</td>>"; html += "<<td>>"; html += "<<a href='http://twitter.com/" + result['from_user'] + "' target='_blank'>>"; html += "<<span style='color:#2FC2EF;font-weight:bold;'>>" + result['from_user'] + ":<</span>>" html += "<</a>>"; html += createLink(result['text']) + "<</br>>"; html += "<</td>>"; html += "<</tr>>";
}
html += "<</table>>";
document.getElementById('content_div').innerHTML = html;
var ary = ptn.exec(text);
while(ary) {
ret = ret.replace(ary[0], "<<a href='" + RegExp.$1 + "' target='_blank'>>" + ary[0] + "<</a>>");
ary = ptn.exec(text);
}
var ary = ptn.exec(text);
while(ary) {
ret = ret.replace(ary[0], "<<a href='http://twitter.com/" + RegExp.$1 + "' target='_blank'>>" + ary[0] + "<</a>>");
ary = ptn.exec(text);
}
return ret;
}
<</script>> <<input type="text" size="16" id="q"/><><input type="button" name="search" value="twitter search" onclick="javascript:search_twitter();"/>> <<div id="content_div"/>> ]]>> <</Content> > <</Module>>