7. The problem of social network development As each social website opens its environment to developers, it exposes an API “ .. But what if you want to build an application that will run on multiple social websites?” Problem: Developers have to learn multiple APIs to publish in multiple environments Solution: OpenSocial allows developers to write applications to a common standard API that will run on multiple websites!
19. Current status on (a few) containers hi5 - launched developer platform recently (80 million users): http://www.hi5networks.com/developer/ MySpace - Developer Platform live and beta Apps Gallery available: http://developer.myspace.com orkut – Sandbox available, launch in test phase, apps available to a subset of users (Estonia) - rolling out further in the coming weeks ning, plaxa – sandboxes available
20.
21.
22.
23. Core Services - People & Friends /** * Request for friend info when the page loads. */ function getData() { var req = opensocial.newDataRequest(); req.add(req.newFetchPersonRequest(VIEWER), 'viewer' ); req.add(req.newFetchPeopleRequest(VIEWER_FRIENDS), 'viewerFriends' ); req.send( onLoadFriends ); }; Getting info on you and your friends :
24. Core Services - People /** * Callback function for returned friend data. */ function onLoadFriends (response) { var viewer = response.get( 'viewer' ).getData(); var html = 'Friends of ' + viewer.getDisplayName() + ‘:<br><ul>’; var viewerFriends = response.get( 'viewerFriends' ).getData(); viewerFriends.each(function(person) { html += '<li>' + person.getDisplayName() + '</li>';}); html += '</ul>'; document.getElementById('message').innerHTML = html; }; Getting info on you and your friends :
25. Core Services - Activities /** * Posting a simple text activity */ function postActivity(text) { var params = {}; params[opensocial.Activity.Field.TITLE] = text; var activity = opensocial.newActivity(params); opensocial.requestCreateActivity(activity, opensocial.CreateActivityPriority.HIGH, callback ); } postActivity("This is a sample activity, created at " + new Date().toString()); Posting an Activity :
26. Core Services - Persistence /** * Storing data */ function populateMyAppData() { var req = opensocial.newDataRequest(); var data1 = Math.random() * 5; var data2 = Math.random() * 100; req.add(req.newUpdatePersonAppDataRequest("VIEWER", "AppField1", data1)); req.add(req.newUpdatePersonAppDataRequest("VIEWER", "AppField2", data2)); req.send(requestMyData); }; Requesting to persist data:
27. Core Services - Persistence /** * Fetching data */ function requestMyData() { var req = opensocial.newDataRequest(); var fields = ["AppField1", "AppField2"]; req.add(req.newFetchPersonRequest( opensocial.DataRequest.PersonId.VIEWER), "viewer"); req.add(req.newFetchPersonAppDataRequest("VIEWER", fields), "viewer_data"); req.send(handleReturnedData); } Requesting to persist data:
28. Core Services - Persistence /** * Displaying persisted data */ function handleReturnedData(data) { var mydata = data.get("viewer_data"); var viewer = data.get("viewer"); me = viewer.getData(); // me is global var var data = mydata[me.getId()]; htmlout += "AppField1: " + data["AppField1"] + "<br/>"; htmlout += "AppField2: " + data["AppField2"] + "<br/>"; var div = document.getElementById('content_div'); div.innerHTML = htmlout; } Displaying the fetched ( persisted ) data:
29.
30.
31.
32.
33.
34. Shindig in Action Running the application Request is made from Client Data is returned and rendered Application Installation Gadget XML is loaded and cached on OpenSocial Container Gadget XML Source
35.
36.
37.
38.
39.
40. Where to find more info on OpenSocial http://www.opensocial.org Specification http://code.google.com/apis/opensocial/ http://code.google.com/opensocial http://code.google.com/p/opensocial-resources Sandboxes http://developer.myspace.com/ http://www.hi5networks.com/developer/ http://opensocial.ning.com/ http://pulse.plaxo.com/pulse/gadgets/ http://code.google.com/apis/orkut/ For container developers http://opensocialapis.blogspot.com/2007/12/lets-get-this-shindig-started.html http://incubator.apache.org/shindig/ http://code.google.com/p/google-caja
41. Where to find more info on OpenSocial This slide deck: slideshare.net/arileicht