このAPIは認証不要です。Twitterで話題になっている情報を取得できる国と都市のリストを取得して、一覧表示します。
<!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>Twitter API:ローカルトレンド関連:trends/abailable(Twitterで話題になっている情報を取得できる国と都市のリストを取得) | 設置サンプル</title> <link rel="stylesheet" type="text/css" href="/content/lib/global.css" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript" src="/content/lib/jquery/jquery.jsonp.js"></script> <!-- JS --> <script type="text/javascript"> $(function(){ var url="http://api.twitter.com/1/trends/available.json?callback={callback}"; $.getJSONP(url, function(json){ var s=""; var ss=""; $.each(json, function(i, item){ if(i==0){ ss+="<tr><th>名称</th><th>URL</th><th>親ID</th><th>国名</th><th>場所の名前</th><th>場所タイプ</th><th>WOEID</th><th>国コード</th></tr>"; } s+="<tr>"; s+="<th>"+item.name+"</th>"; s+="<td>"+item.url+"</td>"; s+="<td>"+item.parentid+"</td>"; s+="<td>"+item.country+"</td>"; s+="<td>"+item.placeType.name+"</td>"; s+="<td>"+item.placeType.code+"</td>"; s+="<td>"+item.woeid+"</td>"; s+="<td>"+item.countryCode+"</td>"; s+="</tr>"; }); $("#res").html("<table><thead>"+ss+"</thead><tbody>"+s+"</tbody></table>"); }); }); </script> <style type="text/css"> table,th,td { font-size:11px; } table { width:99.9%; margin:0; padding:0; border-width:1px; border-style:solid; border-color:#ddd #ccc #ccc #ddd; border-collapse:separate; border-spacing:1px; } table th { padding:2px 5px; border-width:0 1px 1px 0; border-style:solid; border-color:#ccc; color:#536066; background-color:#eee; font-weight:bold; text-align:left; } table td { padding:2px 5px; border-width:1px; border-style:solid; border-color:#eee #ccc #ccc #eee; } table thead th { background-color:#ddd; } table thead td { background-color:#eee; } table thead td.hi { background-color:#ffffcc; } </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>Twitter API:ローカルトレンド関連:trends/abailable(Twitterで話題になっている情報を取得できる国と都市のリストを取得) | 設置サンプル</h1> <p>このAPIは認証不要です。Twitterで話題になっている情報を取得できる国と都市のリストを取得して、一覧表示します。</p> <!-- CODE --> <div id="res"></div> <!-- / CODE --> </div> </body> </html>