Paste Description for Aakash
opensocial get friends, ping server
- Aakash
- Saturday, June 21st, 2008 at 3:54:02pm MDT
- <?xml version="1.0" encoding="UTF-8" ?>
- <Module>
- <ModulePrefs title="List Friends Example">
- <Require feature="opensocial-0.7"/>
- </ModulePrefs>
- <Content type="html">
- <![CDATA[
- <script type="text/javascript">
- /**
- * Request for friend information.
- */
- function getData() {
- var req = opensocial.newDataRequest();
- req.add(req.newFetchPersonRequest(opensocial.DataRequest.PersonId.VIEWER), 'viewer');
- req.add(req.newFetchPeopleRequest(opensocial.DataRequest.Group.VIEWER_FRIENDS), 'viewerFriends');
- req.send(onLoadFriends);
- };
- /**
- * Parses the response to the friend information request and generates
- * html to list the friends along with their display name.
- *
- * @param {Object} dataResponse Friend information that was requested.
- */
- function onLoadFriends(dataResponse) {
- var viewer = dataResponse.get('viewer').getData();
- var html = 'Friends of ' + viewer.getDisplayName();
- html += ':<br><ul>';
- var viewerFriends = dataResponse.get('viewerFriends').getData();
- viewerFriends.each(function(person) {
- html += '<li>' + person.getDisplayName() + '</li>';
- });
- html += '</ul>';
- document.getElementById('message').innerHTML = html;
- };
- function makeServerRequest() { var params = {};
- params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.TEXT;
- var url = "http://dbe44284.joyent.us/test.php";
- gadgets.io.makeRequest(url, response, params);};
- function response(obj) {document.getElementById('server').innerHTML=obj.text;}
- </script>
- <button onClick="getData()">Fetch Friends from orkut.com</button>
- <div id="message"> </div>
- <button onClick="makeServerRequest()">Make request to remote server</button>
- <div id="server"></div>
- ]]>
- </Content>
- </Module>
Paste Details
Tags: opensocial
advertising
Update the Post
Either update this post and resubmit it with changes, or make a new post.
You may also comment on this post.
Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.