a pastebin project

Paste Description for Aakash

opensocial get friends, ping server

Aakash

  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <Module>
  3.  <ModulePrefs title="List Friends Example">
  4.    <Require feature="opensocial-0.7"/>
  5.  </ModulePrefs>
  6.  <Content type="html">
  7.  
  8.  <![CDATA[
  9.  
  10. <script type="text/javascript">
  11.  
  12. /**
  13.   * Request for friend information.
  14.   */
  15.   function getData() {   
  16.     var req = opensocial.newDataRequest();
  17.     req.add(req.newFetchPersonRequest(opensocial.DataRequest.PersonId.VIEWER), 'viewer');
  18.     req.add(req.newFetchPeopleRequest(opensocial.DataRequest.Group.VIEWER_FRIENDS), 'viewerFriends');
  19.     req.send(onLoadFriends);
  20.   };
  21.  
  22. /**
  23.   * Parses the response to the friend information request and generates
  24.   * html to list the friends along with their display name.
  25.   *
  26.   * @param {Object} dataResponse Friend information that was requested.
  27.   */
  28.   function onLoadFriends(dataResponse) {
  29.     var viewer = dataResponse.get('viewer').getData();
  30.     var html = 'Friends of ' + viewer.getDisplayName();
  31.     html += ':<br><ul>';
  32.     var viewerFriends = dataResponse.get('viewerFriends').getData();
  33.     viewerFriends.each(function(person) {
  34.       html += '<li>' + person.getDisplayName() + '</li>';
  35.     });
  36.     html += '</ul>';
  37.     document.getElementById('message').innerHTML = html;
  38.   };
  39. function makeServerRequest() {    var params = {};
  40. params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.TEXT; 
  41. var url = "http://dbe44284.joyent.us/test.php";
  42. gadgets.io.makeRequest(url, response, params);};
  43. function response(obj) {document.getElementById('server').innerHTML=obj.text;}
  44.  
  45.   </script>
  46.   <button onClick="getData()">Fetch Friends from orkut.com</button>
  47.   <div id="message"> </div>
  48.   <button onClick="makeServerRequest()">Make request to remote server</button>
  49.   <div id="server"></div>
  50.   ]]>
  51.   </Content>
  52. </Module>

advertising

Create a Paste

Please enter your new post below (or upload a file instead):





Please note that information posted here will not expire by default. If you 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.

worth-right
worth-right