Mixi アプリ VIEWERの情報表示
2020年2月15日 (土) 07:34時点におけるPiroto (トーク | 投稿記録)による版 (ページの作成:「==mixi アプリ VIEWERの情報表示== [mixi アプリ] ===閲覧者情報の表示サンプル=== File:0801_mixi_app_test01.jpg ===ソース=== ====重要API=…」)
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 "parse limit over";
}
var tbl = "
"; tbl += ""; for (prop in obj) {
var type = typeof(eval("obj." + prop));
var blnkt = (type == "function")?"()":"";
tbl += "";
tbl += "";
tbl += "";
if (type == 'object') {
tbl += "";
} else {
tbl += "";
}tbl += ""; } tbl += "
| Property | Type | Value | |
|---|---|---|---|
| " + prop + " | " + type + " | " + printPropertiesAsTable(eval("obj." + prop), dpth++) + " | " + eval("obj." + prop + blnkt) + " |
";
return tbl;
}
gadgets.util.registerOnLoadHandler(request);
</script>
]]> </Content> </Module>
© 2006 矢木浩人
