!!!mixi アプリ VIEWERの情報表示 [mixi アプリ] !!閲覧者情報の表示サンプル {{ref_image mixi_app_test01.jpg}} !!ソース !重要API ,API,概要 ,[newDataRequest|http://code.google.com/intl/ja/apis/opensocial/docs/0.8/reference/#opensocial.DataRequest],コンテナから友だちのデータ、プロフィール、アプリケーション データ、アクティビティなどのソーシャル情報を要求するために使用 ,[newFetchPersonRequest|http://code.google.com/intl/ja/apis/opensocial/docs/0.8/reference/#opensocial.DataRequest.newFetchPersonRequest],指定した個人 ID のプロフィールを要求するアイテムを作成。[Person|http://code.google.com/intl/ja/apis/opensocial/docs/0.8/reference/#opensocial.Person] オブジェクトを返す // 閲覧者情報取得要求 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 += "
PropertyTypeValue
" + prop + "" + type + "" + printPropertiesAsTable(eval("obj." + prop), dpth++) + "" + eval("obj." + prop + blnkt) + "
"; return tbl; } gadgets.util.registerOnLoadHandler(request);
]]>