「Mixi アプリ VIEWERの情報表示」の版間の差分
ナビゲーションに移動
検索に移動
| (同じ利用者による、間の1版が非表示) | |||
| 1行目: | 1行目: | ||
| − | ==mixi アプリ VIEWERの情報表示== | + | ==[[mixi アプリ VIEWERの情報表示]]== |
| − | [[mixi アプリ]] | + | [[mixi アプリ]] | |
===閲覧者情報の表示サンプル=== | ===閲覧者情報の表示サンプル=== | ||
[[File:0801_mixi_app_test01.jpg]] | [[File:0801_mixi_app_test01.jpg]] | ||
| 19行目: | 19行目: | ||
<Module> | <Module> | ||
<ModulePrefs title="hello world example"> | <ModulePrefs title="hello world example"> | ||
| − | < | + | <[[R]]equire feature="opensocial-0.8"/> |
</ModulePrefs> | </ModulePrefs> | ||
<Content type="html"> | <Content type="html"> | ||
| 26行目: | 26行目: | ||
// 閲覧者情報取得要求 | // 閲覧者情報取得要求 | ||
function request() { | function request() { | ||
| − | var req = opensocial. | + | var req = opensocial.newData[[R]]equest(); |
| − | req.add(req.newFetchPersonRequest("VIEWER"), " | + | req.add(req.newFetchPersonRequest("VIEWER"), "[[vi]]ewer_data"); |
req.send(response); | req.send(response); | ||
} | } | ||
// 閲覧者情報取得応答 | // 閲覧者情報取得応答 | ||
| − | function response( | + | function response(data[[R]]esponse) { |
| − | var | + | var [[vi]]ewer = dataResponse.get("[[vi]]ewer_data").getData(); |
| − | document.getElementById("viewer_inf"). | + | document.getElementById("viewer_inf").inner[[HTML]] |
| − | = printPropertiesAsTable( | + | = printPropertiesAsTable([[vi]]ewer, 0); |
} | } | ||
// 閲覧者情報表示 | // 閲覧者情報表示 | ||
| 61行目: | 61行目: | ||
gadgets.util.registerOnLoadHandler(request); | gadgets.util.registerOnLoadHandler(request); | ||
</script> | </script> | ||
| − | <div id=" | + | <div id="[[vi]]ewer_inf"/> |
]]> | ]]> | ||
</Content> | </Content> | ||
</Module> | </Module> | ||
2020年2月16日 (日) 04:29時点における最新版
mixi アプリ VIEWERの情報表示
mixi アプリ |
閲覧者情報の表示サンプル
ソース
重要API
| API | 概要 |
|---|---|
| newDataRequest | コンテナから友だちのデータ、プロフィール、アプリケーション データ、アクティビティなどのソーシャル情報を要求するために使用 |
| http://code.google.com/intl/ja/apis/opensocial/docs/0.8/reference/#opensocial.DataRequest.newFetchPersonRequest] | 指定した個人 ID のプロフィールを要求するアイテムを作成。[Person] オブジェクトを返す |
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="hello world example">
<Require feature="opensocial-0.8"/>
</ModulePrefs>
<Content type="html">
<![CDATA[
<script type="text/javascript">
// 閲覧者情報取得要求
function request() {
var req = opensocial.newDataRequest();
req.add(req.newFetchPersonRequest("VIEWER"), "viewer_data");
req.send(response);
}
// 閲覧者情報取得応答
function response(dataResponse) {
var viewer = dataResponse.get("viewer_data").getData();
document.getElementById("viewer_inf").innerHTML
= printPropertiesAsTable(viewer, 0);
}
// 閲覧者情報表示
function printPropertiesAsTable(obj, dpth) {
if (dpth > 5) {
return "<b>parse limit over</b>";
}
var tbl = "<table border='1'>";
tbl += "<tr><th>Property</th><th>Type</th><th>Value</th></tr>";
for (prop in obj) {
var type = typeof(eval("obj." + prop));
var blnkt = (type == "function")?"()":"";
tbl += "<tr>";
tbl += "<td>" + prop + "</td>";
tbl += "<td>" + type + "</td>";
if (type == 'object') {
tbl += "<td>" + printPropertiesAsTable(eval("obj." + prop), dpth++) + "</td>";
} else {
tbl += "<td>" + eval("obj." + prop + blnkt) + "</td>";
}
tbl += "</tr>";
}
tbl += "</table>";
return tbl;
}
gadgets.util.registerOnLoadHandler(request);
</script>
<div id="viewer_inf"/>
]]>
</Content>
</Module>
© 2006 矢木浩人
