Recent Posts
Recent Comments
DevTzu
[OpenSocial] 전체 친구 목록 불러오기 본문
반응형
var containerDomain; var containerType; var allFriends = []; var limitPerRequest = 20; var requestIdx = 0; function initApps() { allFriends = []; requestIdx = 0; /* 컨테이너 종류 - www.natecontainer.com : 일촌 컨테이너 OpenSocial 0.8 지원 - cyworld.natecontainer.com : 일촌 컨테이너 OpenSocial 0.9 지원 - nateon.natecontainer.com : 네이트온 친구 컨테이너 OpenSocial 0.9 지원 (네이트온은 0.9만 지원) */ // 컨테이너 판별 containerDomain = opensocial.getEnvironment().getDomain(); containerType = (containerDomain == 'nateon.natecontainer.com' ? 'nateon' : 'cyworld'); limitPerRequest = (containerType == 'cyworld' ? 20 : 200); request(); } function request() { var idspec = opensocial.newIdSpec({ "userId" : "OWNER" , "groupId" : "FRIENDS"}); var req = opensocial.newDataRequest(); var params = {}; params[opensocial.DataRequest.PeopleRequestFields.FIRST] = requestIdx * limitPerRequest; params[opensocial.DataRequest.PeopleRequestFields.MAX] = limitPerRequest; req.add(req.newFetchPersonRequest(opensocial.IdSpec.PersonId.OWNER), "get_owner"); req.add(req.newFetchPeopleRequest(idspec, params), "get_friends"); req.send(response); } function response(dataResponse) { var owner = dataResponse.get('get_owner').getData(); var friends = dataResponse.get('get_friends').getData(); var friendsIdx; friends.each( function(person) { if (person) { friendsIdx = allFriends.length; allFriends[friendsIdx] = {}; allFriends[friendsIdx]['id'] = person.getId(); allFriends[friendsIdx]['displayName'] = person.getDisplayName(); allFriends[friendsIdx]['thumbnail'] = person.getField(opensocial.Person.Field['THUMBNAIL_URL']); allFriends[friendsIdx]['profileUrl'] = person.getField(opensocial.Person.Field['PROFILE_URL']); } }); if (friends.getTotalSize() > (requestIdx + 1) * limitPerRequest) { requestIdx++; request(); } else { displayFriends(allFriends); } } function displayFriends(allFriends) { var html = ''; for (var i = 0; i < allFriends.length; i++) { html += ' '; html += '
'; } document.getElementById("message").innerHTML = html; } // Execute the request function when the application is finished loading. gadgets.util.registerOnLoadHandler(initApps);- ' + '
'; html += '- DisplayName : ' + allFriends[i].displayName + ' (' + allFriends[i].id + ')
- ' + '
'; html += '- Thumbnail : ' + allFriends[i].thumbnail + '
- ' + '
'; html += '- ProfileUrl : ' + allFriends[i].profileUrl + '
]]>
반응형
'study' 카테고리의 다른 글
[Selector] ID Selector $('#id') (0) | 2011.09.10 |
---|---|
[OpenSocial] XML코드에 실버라이트 삽입 예제 (0) | 2011.03.25 |
[OpenSocial] VIEWER의 프로필 정보 가져오기 (0) | 2011.03.25 |
객체지향 프로그래밍 학습 (0) | 2011.01.24 |
#JavaScript - blendTrans Filter (부드러운 이미지 변경) (0) | 2010.07.22 |
Comments