| ページ一覧 | ブログ | twitter |  書式 | 書式(表) |

MyMemoWiki

Mixi アプリ マイミクのリスト表示

提供: MyMemoWiki
2020年2月15日 (土) 08:37時点におけるPiroto (トーク | 投稿記録)による版
ナビゲーションに移動 検索に移動

mixi アプリ マイミクのリスト表示

mixi アプリ |

マイミクのリストを表示するサンプル

0799 mixi app mymx.jpg

ソース

重要API

API 概要
http://code.google.com/intl/ja/apis/opensocial/docs/0.8/reference/#opensocial.newIdSpec] [IdSpce] オブジェクトを作成
http://code.google.com/intl/ja/apis/opensocial/docs/0.8/reference/#opensocial.DataRequest.newFetchPeopleRequest] サーバーから友だちを要求するアイテムを作成。[Collection] <Person> オブジェクトを返す
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <Module>
  3. <ModulePrefs title="list_friends">
  4. <Require feature="opensocial-0.8"/>
  5. </ModulePrefs>
  6. <Content type="html">
  7. <![CDATA[
  8. <script type="text/javascript">
  9. // 閲覧者の友人コレクション取得要求
  10. function request() {
  11. var idspec = opensocial.newIdSpec({ "userId" : "VIEWER", "groupId" : "FRIENDS" });
  12. var req = opensocial.newDataRequest();
  13. req.add(req.newFetchPeopleRequest(idspec), "friends");
  14. req.send(response);
  15. }
  16. // 閲覧者の友人コレクション取得応答
  17. function response(dataResponse) {
  18. var friends = dataResponse.get("friends").getData();
  19. document.getElementById("friend_list").innerHTML = printFriendsList(friends);
  20. }
  21. // 閲覧者の友人リスト表示
  22. function printFriendsList(friends) {
  23. var html = "<table border='1'>";
  24. html += "<tr><th>Image</th><th>NickName</th></tr>";
  25. friends.each( function(friend) {
  26. html += "<tr>";
  27. html += "<td><img src='" + friend.getField("thumbnailUrl") + "'></td>";
  28. html += "<td><a href='" + friend.getField("profileUrl") + "' target='_blank'>" + friend.getDisplayName() + "</a></td>";
  29. html += "</tr>";
  30. });
  31. html += "</table>";
  32. return html;
  33. }
  34. gadgets.util.registerOnLoadHandler(request);
  35. </script>
  36. <div id="friend_list"/>
  37. ]]>
  38. </Content>
  39. </Module>