google devfest bangkok - opensocial

123
OpenSocial a standard for the social web Patrick Chanezon [email protected] Bangkok October 31 2008

Post on 13-Sep-2014

4.447 views

Category:

Technology


2 download

DESCRIPTION

Introduction to OpenSocial for Google Devfest Bangkok.

TRANSCRIPT

Page 1: Google Devfest Bangkok - OpenSocial

1

OpenSociala standard for the social web

Patrick [email protected]

BangkokOctober 31 2008

Page 2: Google Devfest Bangkok - OpenSocial

2

OpenSocial’s goal:Make the web more social

2

Page 3: Google Devfest Bangkok - OpenSocial

3

What does “social” mean?

“Eliette, what do you do with your friends?”

Page 4: Google Devfest Bangkok - OpenSocial

4

This work by Eliette Chanezon is licensed under a Creative Commons Attribution-Share Alike 3.0 License

What does “social” mean?

Page 5: Google Devfest Bangkok - OpenSocial

5

This work by Eliette Chanezon is licensed under a Creative Commons Attribution-Share Alike 3.0 License

What does “social” mean?

Page 6: Google Devfest Bangkok - OpenSocial

6

This work by Eliette Chanezon is licensed under a Creative Commons Attribution-Share Alike 3.0 License

What does “social” mean?

Page 7: Google Devfest Bangkok - OpenSocial

7

This work by Eliette Chanezon is licensed under a Creative Commons Attribution-Share Alike 3.0 License

What does “social” mean?

Page 8: Google Devfest Bangkok - OpenSocial

8

This work by Eliette Chanezon is licensed under a Creative Commons Attribution-Share Alike 3.0 License

What does “social” mean?

Page 9: Google Devfest Bangkok - OpenSocial

9

This work by Eliette Chanezon is licensed under a Creative Commons Attribution-Share Alike 3.0 License

What does “social” mean?

Page 10: Google Devfest Bangkok - OpenSocial

10

What does “social” mean?

“Internet, what do you do with your friends?”

Page 11: Google Devfest Bangkok - OpenSocial

11

“We look at each other”

Page 12: Google Devfest Bangkok - OpenSocial

1212

“Talking”

Page 13: Google Devfest Bangkok - OpenSocial

1313

“Laughing”

Page 14: Google Devfest Bangkok - OpenSocial

1414

“We help each other”

Page 15: Google Devfest Bangkok - OpenSocial

1515

“We read together”

Page 16: Google Devfest Bangkok - OpenSocial

1616

“We do projects together”

Page 17: Google Devfest Bangkok - OpenSocial

17

The social internet

A social website..•Provides a feature that becomes more engaging as the number of usersgrows.•Uses relationships between people to present users interesting information.

Page 18: Google Devfest Bangkok - OpenSocial

18

The social internetSome social websites...

Page 19: Google Devfest Bangkok - OpenSocial

19

The social internetA social website..•Has overhead to manage users and relationships.•Grows slowly because users must sign up to use the site.

What if we removethe overhead?•Developers can focuson providingfeatures, notmanaging users.

Page 20: Google Devfest Bangkok - OpenSocial

20

The social internetA social network..•Manages large numbers of users and relationships.•Is slow to add new features.

Page 21: Google Devfest Bangkok - OpenSocial

21

The social internetMany social networks...

Page 22: Google Devfest Bangkok - OpenSocial

22

The social internetHow do we add new features to social networks?•Make the social network a platform.•Give creative developers the tools to add the features themselves.

Page 23: Google Devfest Bangkok - OpenSocial

23

The social internetA social application...•Lets the social network manage users and relationships.•Adds new features to the social network.•Lets users “install” the application without signing up for new accounts.•Grows quickly because users are already communicating with each other.

Page 24: Google Devfest Bangkok - OpenSocial

24

The social internetLots of social apps...

Page 25: Google Devfest Bangkok - OpenSocial

2525

Need for a social APIHow do we put apps in social networks?

Page 26: Google Devfest Bangkok - OpenSocial

26

A day in the life of a social app developer

Page 27: Google Devfest Bangkok - OpenSocial

27

A day in the life of a social app developer

Page 28: Google Devfest Bangkok - OpenSocial

28

A day in the life of a social app developer

Page 29: Google Devfest Bangkok - OpenSocial

29

A day in the life of a social app developer

Page 30: Google Devfest Bangkok - OpenSocial

30

A day in the life of a social app developer

Page 31: Google Devfest Bangkok - OpenSocial

31

A day in the life of a social app developer

Page 32: Google Devfest Bangkok - OpenSocial

32

Introduction to OpenSocialNumbers:•19+ implemented Containers•40+ committed Containers•3000+ applications•400,000,000+ of users

In Thailand:

8 M users

Page 33: Google Devfest Bangkok - OpenSocial

33Today: 375 Million User Reach

Page 34: Google Devfest Bangkok - OpenSocial

34

OpenSocial “Containers”

Page 35: Google Devfest Bangkok - OpenSocial

35

Where is OpenSocial live today?

• Live to Users:• MySpace• orkut• hi5• Freebar• Friendster• Webon from Lycos• IDtail• YiQi• Netlog• Hyves• LinkedIn - New!

Live Developer Sandboxes:• iGoogle• imeem• CityIN• Tianya• Ning• Plaxo Pulse• Mail.ru• lokalisten• Viadeo• 51.com - New!• Yahoo! - New!• MyAOL! - New!

Full List:http://code.google.com/apis/opensocial/gettingstarted.html

Page 36: Google Devfest Bangkok - OpenSocial

36

Containers in the region

Page 37: Google Devfest Bangkok - OpenSocial

37

The OpenSocial APIs

Client-side:•Gadgets XML•Gadgets JavaScript•OpenSocial JavaScript

Server-side:•RESTful protocol•RPC protocol

Versions:•0.6 - Client-side APIs introduced•0.7 - Server-side APIs introduced•0.81 (current) - Server-side APIs finalized

Page 38: Google Devfest Bangkok - OpenSocial

38

OpenSocial is moving fast: bews from this week!

• LinkedIn launched to 100% of users, and has a REST endpoint

• Mail.ru launched to users

• 51.com (large Chinese network) launchedhttp://developers.51.com

• Yahoo! launch launched a sandbox --

• Tools:

• Announced the OpenSocial Dev App

• http://wiki.opensocial.org is live

• Community updates:

• OpenSocial is having a birthday event on November 13 in San Francisco

• OpenSocial Foundation community election: vote by Monday!

Page 39: Google Devfest Bangkok - OpenSocial

39

Popular OpenSocial apps on hi5 in Thailand

• Engrish

• Daily Pablo -- get a new Picasso painting on your profile every day

• Kitten Club & KittyPix -- pictures of kittens

• PuppyPix -- pictures of puppies

• BuddyPoke! -- Poke your friends, powered by Google App Engine

• Soccer

• Speed Racing! -- design your car and engine and race your friends.

Page 40: Google Devfest Bangkok - OpenSocial

4040

GadgetsNot widgets, not sprockets, not gidgets, not wadgets

Page 41: Google Devfest Bangkok - OpenSocial

41

GadgetsA gadget spec:•Is an XML file.•Defines metadata about an OpenSocial app.•Is highly cacheable and does not need a high performance server.

Gadgets use existing web standards•XML to define metadata.•HTML for markup.•JavaScript for interactivity.•CSS for presentation.

Page 42: Google Devfest Bangkok - OpenSocial

42

GadgetsA gadget server:•Takes the gadget spec as input.•Performs optimizations on the gadget spec.•Outputs HTML, JavaScript, and CSS as one document.

Page 43: Google Devfest Bangkok - OpenSocial

43

Gadgets

A container:•Displays the social network’s user interface.•Opens an IFrame to the rendered gadget.

Containers and gadgetservers are both run bythe social network, butdo not need to be onthe same machine, oreven domain.

Page 44: Google Devfest Bangkok - OpenSocial

44

GadgetsExample gadget XML spec:•Uses HTML to print “Hello World”.•Colors the text red with CSS.•Dynamically adjusts the height of the gadget with JavaScript.

<?xml version="1.0" encoding="UTF-8" ?><Module><ModulePrefs title="Hello World!"> <Require feature="dynamic-height" /> </ModulePrefs> <Content type="html"> <![CDATA[<h1>Hello World</h1>

<style type="text/css"> h1 { color: #dd0000; }</style><script type="text/javascript"> gadgets.window.adjustHeight();

</script> ]]> </Content></Module>

Page 45: Google Devfest Bangkok - OpenSocial

45

GadgetsRequesting the gadget XML spec:1. The client requests an app to be rendered.

Page 46: Google Devfest Bangkok - OpenSocial

46

GadgetsRequesting the gadget XML spec:1. The client requests an app to be rendered.2. The container fetches the gadget XML spec from its host.

Page 47: Google Devfest Bangkok - OpenSocial

47

GadgetsRequesting the gadget XML spec:1. The client requests an app to be rendered.2. The container fetches the gadget XML spec from its host.3. The container renders the gadget into HTML, which is displayed to the client.

Page 48: Google Devfest Bangkok - OpenSocial

48

GadgetsRequesting the gadget XML spec:•Because the gadget spec is simple, it can be cached easily.•Caching reduces the load on your server, great when you have millions ofusers.

Page 49: Google Devfest Bangkok - OpenSocial

49

GadgetsRequesting a cached gadget XML spec:1.The client requests an app to be rendered. The container already has a copy of the spec stored in its cache.

Page 50: Google Devfest Bangkok - OpenSocial

50

GadgetsRequesting a cached gadget XML spec:1.The client requests an app to be rendered. The container already has a copy of the spec stored in its cache.2.The container renders the gadget into HTML, which is displayed to the client.

Page 51: Google Devfest Bangkok - OpenSocial

51

GadgetsWhat kind of rewriting is done by the gadget server?•Rewrite links to use content proxies.•Rewrite relative links to full paths (some containers).•Return only content for the current view.

Page 52: Google Devfest Bangkok - OpenSocial

52

GadgetsWhat are views?•Gadgets can render in different locations on a container.•Rendering area changes from small to large.•Certain pages might be public, some are private.•Containers may have different policies depending on the page,especially when the gadget displays ads.•Views provide a way for gadgets to provide different functionality dependingon where it is rendered.

Page 53: Google Devfest Bangkok - OpenSocial

53

Gadgets

iGoogle "home" view:•On iGoogle, the "home" view is a small,private page that does not allow ads.

Page 54: Google Devfest Bangkok - OpenSocial

54

Gadgets

54

iGoogle "canvas" view:•Large private view, allows ads.

Page 55: Google Devfest Bangkok - OpenSocial

55

GadgetsWorking with views in the gadget XML:•<Content> sections are repeated for each view.•Add a view="view name" attribute to each section.•Content sections may support multiple views, for exampleview="home,canvas"

<?xml version="1.0" encoding="UTF-8" ?><Module><ModulePrefs title="Hello World!"> <Require feature="dynamic-height" /> </ModulePrefs> <Content type="html" view="home"> <![CDATA[ ... ]]></Content> <Content type="html" view="canvas"> <![CDATA[... ]]> </Content></Module>

Page 56: Google Devfest Bangkok - OpenSocial

56

GadgetsJavaScript utility functions for gadgets:•gadgets.io.makeRequest()Make cross-domain AJAX calls to remote servers.•gadgets.json.parse() and gadgets.json.stringify()Native JSON support.•gadgets.util.escapeString()Make text safe for display via innerHTML.•gadgets.util.registerOnLoadHandler()Execute code when the page is finished loading.

Page 57: Google Devfest Bangkok - OpenSocial

57

Gadgets

gadgets.io.makeRequest():•Make cross-domain AJAX calls to remote servers.

Remote content:•Most interesting gadgets will need towork with content stored on differentservers.•AJAX cannot cross domains, so youcannot request content from your ownserver.•JSONP is only really good for one-waydata transfer.•Gadgets with millions of users canoverwhelm a remote site.

Page 58: Google Devfest Bangkok - OpenSocial

58

GadgetsRequesting remote content:1.The rendered app calls gadgets.io.makeRequest() to fetch remote content. This call is sent to the container.

Page 59: Google Devfest Bangkok - OpenSocial

59

GadgetsRequesting remote content:1.The rendered app calls gadgets.io.makeRequest() to fetch remote content. This call is sent to the container.2.The container requests content from the specified URL.

Page 60: Google Devfest Bangkok - OpenSocial

60

GadgetsRequesting remote content:1.The rendered app calls gadgets.io.makeRequest() to fetch remote content. This call is sent to the container.2.The container requests content from the specified URL.3.The container returns the response to the application, which renders the data.

Page 61: Google Devfest Bangkok - OpenSocial

61

Gadgets

Add extra features to your gadget:•dynamic-height - Change the size of your gadget in the container.•views - Navigate between different surfaces of the container.•skins - Make your gadget change its styles to match the container.•Containers may offer custom features...

<?xml version="1.0" encoding="UTF-8" ?><Module><ModulePrefs title="Hello World!"> <Require feature="dynamic-height" /> </ModulePrefs> <Content type="html"> <![CDATA[... ]]> </Content></Module>

Page 62: Google Devfest Bangkok - OpenSocial

62

Gadgets

<?xml version="1.0" encoding="UTF-8" ?><Module><ModulePrefs title="Hello Social!"> <Requirefeature="opensocial-0.8" /> </ModulePrefs> <Contenttype="html"> <![CDATA[ ... ]]></Content></Module>

The OpenSocial JavaScript API is a gadget feature, too!

Page 63: Google Devfest Bangkok - OpenSocial

6363

The OpenSocial JavaScript API“It's people!”

Page 64: Google Devfest Bangkok - OpenSocial

64

The OpenSocial JavaScript APIRepresenting users:•Client-side, users must work with the VIEWER and the OWNER.

Page 65: Google Devfest Bangkok - OpenSocial

65

The OpenSocial JavaScript API

Multiple personalities:•When you visit your own profile, you are both the VIEWER and the OWNER.

Page 66: Google Devfest Bangkok - OpenSocial

66

The OpenSocial JavaScript APIOpenSocial requests:•An OpenSocial DataRequest is created.•Requests are added to the DataRequest.•The DataRequest is sent to the server asynchronously.•When the request finishes, the supplied callback will be called.

function request() { var req = opensocial.newDataRequest();req.add(req.newFetchPersonRequest("OWNER"), "get_owner"); req.add(req.newFetchPersonRequest("VIEWER"), "get_viewer"); req.add(req.newFetchActivitiesRequest("VIEWER"), "vactivities"); req.add(req.newFetchPersonAppDataRequest("OWNER", "*"), "odata"); ... req.send(response);};

function response(data) { ... };

gadgets.util.registerOnLoadHandler(request);

Page 67: Google Devfest Bangkok - OpenSocial

67

The OpenSocial JavaScript APIOpenSocial responses:•Responses are bundled according to the keys specified in the request.•Check for an error at the global response level.•Check for an error at the specific response level.•Use getData() to retrieve the actual information in a request.

function response(data) { if (data.hadError()) { if (data.get("get_owner").hadError()) { ... } if (data.get("get_viewer").hadError()) { ... } ... } var owner = data.get("get_owner").getData(); var viewer = data.get("get_viewer").getData();};

Page 68: Google Devfest Bangkok - OpenSocial

68

The OpenSocial JavaScript APIWorking with people:

• opensocial.Person - JavaScript representation of a user.

Page 69: Google Devfest Bangkok - OpenSocial

69

The OpenSocial JavaScript APIRequest one person:

req.add(req.newFetchPersonRequest(idspec, opt_params), "key");

• idspec can be either “VIEWER”, “OWNER” or an ID number.• opt_params contains extra request parameters, such as which profile

fields to fetch.

newFetchPersonRequest responses:

var owner = data.get("key").getData();alert(owner.getDisplayName());

• Data contains a single opensocial.Personobject.

• Person objects can contain lots of information,such as addresses, companies, phone numbers,favorite movies, and thumbnail urls.

Page 70: Google Devfest Bangkok - OpenSocial

70

The OpenSocial JavaScript APIMethods available on an OpenSocial Person:

• getDisplayName()Gets a text display name for this person; guaranteed to return a usefulstring. getField(key, opt_params)Gets data for this person that is associated with the specified key. getId()Gets an ID that can be permanently associated with this person.isOwner()Returns true if this person object represents the ownerof the current page. isViewer()Returns true if this person object represents thecurrently logged in user.

Page 71: Google Devfest Bangkok - OpenSocial

71

• ABOUT_MEACTIVITIESADDRESSESAGEBODY_TYPEBOOKSCARSCHILDRENCURRENT_LOCATIONDATE_OF_BIRTHDRINKEREMAILSETHNICITYFASHIONFOODGENDERHAPPIEST_WHENHAS_APPHEROESHUMORIDINTERESTS

• JOB_INTERESTSJOBSLANGUAGES_SPOKEN• LIVING_ARRANGEMENTLOOKING_FORMOVIESMUSICNAMENETWORK_PRESENCENICK

NAMEPETSPHONE_NUMBERSPOLITICAL_VIEWSPROFILE_SONGPROFILE_URLPROFILE_VIDEOQUOTESRELATIONSHIP_STATUSRELIGIONROMANCESCARED_OFSCHOOLS

The OpenSocial JavaScript APIAn OpenSocial Person's fields:

• SEXUAL_ORIENTATION• SMOKER• SPORTSSTATUSTAGS• THUMBNAIL_URL• TIME_ZONETURN_OFFSTURN_ONSTV_SHOWSURLS

Page 72: Google Devfest Bangkok - OpenSocial

72

The OpenSocial JavaScript APIWorking with people:

• A Collection represents many opensocial.Person objects.

Page 73: Google Devfest Bangkok - OpenSocial

73

The OpenSocial JavaScript APIRequest many people:

var idspec = opensocial.newIdSpec({ “userId” : “OWNER”, “groupId” : “FRIENDS”});req.add(req.newFetchPeopleRequest(idspec, opt_params), "key");

• idspec is an object that can represent groups of people. “userId” can be“VIEWER” or “OWNER” or an ID, and “groupId” can be “SELF”,“FRIENDS”, or the name of a group.

• opt_params contains extra request parameters, such as which profilefields to fetch, and how to order or filter the returned people.

newFetchPersonRequest responses:var owner_friends = data.get("key").getData();owner_friends.each(function (person) { alert(person.getDisplayName());});

• Data contains a Collection of opensocial.Personobjects. Iterate over these by using the each() method.

Page 74: Google Devfest Bangkok - OpenSocial

74

The OpenSocial JavaScript APIWorking with data:

• Persistent data gives apps key, value storage directly on the container.• String only, but conversion to JSON allows for storage of complex objects.• Storage per app per user - scales well with growth.• Ideal for settings, customizations.

Page 75: Google Devfest Bangkok - OpenSocial

75

The OpenSocial JavaScript APISet persistent data:

req.add(req.newUpdatePersonAppDataRequest(idspec, key, value));

• idspec can only be “VIEWER”.• key is the name under which this data will be stored.• value is a string representing the data to store.

Page 76: Google Devfest Bangkok - OpenSocial

76

The OpenSocial JavaScript APIFetch persistent data:

var idspec = opensocial.newIdSpec({ "userId" : "OWNER", "groupId" : "SELF"});req.add(req.newFetchPersonAppDataRequest(idspec, keys), "key");req.add(req.newFetchPersonRequest("OWNER"), "ownerkey");

• idspec is an object that can represent groups of people, the same asnewFetchPeopleRequest.

• keys is a list of persistent data keys to retrieve the data for.• The owner is requested because the data returned is indexed by user ID

and we want the owner’s data.

newFetchPersonAppDataRequest responses:

var app_data = data.get("key").getData();var value = app_data[owner.getId()][key];

Page 77: Google Devfest Bangkok - OpenSocial

77

The OpenSocial JavaScript APIFetch persistent data:

{ "1234567890" : { "key1" : "value1" }, "2345678901" : { "key1" : "value2" }}

• Data is returned as an object indexed by ID number, then as an objectindexed by key name, even if there is only data returned for one user!

{ "1234567890" : { "key1" : "value1" } }

• Multiple people:

{ "1234567890" : { "key1" : "value1", "key2" : "value2" }}

• One person, multiple keys:

Page 78: Google Devfest Bangkok - OpenSocial

78

The OpenSocial JavaScript APIWorking with activities:

• API to post information about what users are doing with your app.• Many containers have support for images and some HTML.• Channel to grow your application.

orkut MySpace hi5

Page 79: Google Devfest Bangkok - OpenSocial

79

The OpenSocial JavaScript APIPost an activity:

function postActivity(text) { var params = {}; params[opensocial.Activity.Field.TITLE] = text; var activity = opensocial.newActivity(params); opensocial.requestCreateActivity(activity, opensocial.CreateActivityPriority.HIGH, callback);};

• Assign the activity text to the TITLE field.• Call opensocial.newActivity() to create a new Activity instance.• Call opensocial.requestCreateActivity() to post the activity to the

container.

Page 80: Google Devfest Bangkok - OpenSocial

8080

RESTful and RPC protocolsServers talking to servers

Page 81: Google Devfest Bangkok - OpenSocial

81

RESTful and RPC protocolsOpens new development models•Background processing.•Easier Flash integration.•Mobile applications.

Page 82: Google Devfest Bangkok - OpenSocial

82

RESTful and RPC protocolsCommunication methods:•RESTful (Representational State Transfer)•RPC (Remote Procedure Call)

Formats:•XML•JSON•AtomPub

Page 83: Google Devfest Bangkok - OpenSocial

83

RESTful and RPC protocolsREST:•Resources are URLs.

/people/{guid}/@all

• All people connected to the given user:Example - People:

/people/{guid}/@friends

• All friends of the given user:

/people/{guid}/@self

• Profile of the given user:

/people/@me/@self

• Profile of the authenticated user:

/people/@supportedFields

• Supported Person fields:

Page 84: Google Devfest Bangkok - OpenSocial

84

RESTful and RPC protocols

• Response format (JSON, XML, AtomPub)

• Request extra fields

• Filtering:

• Paging:

fields={-join|,|field}.

filterBy={fieldname}filterOp={operation}filterValue={value}updatedSince={xsdDateTime}networkDistance={networkDistance}

count={count}sortBy={fieldname} sortOrder={order}startIndex={startIndex}

format={format}

Querystring parameters customize requests:

Page 85: Google Devfest Bangkok - OpenSocial

85

<person xmlns="http://ns.opensocial.org/2008/opensocial"> <id></id><displayName></displayName> <name> <unstructured>Jane Doe</unstructured></name> <gender>female</gender></person>

RESTful and RPC protocolsREST responses (Person):

{ "id" : "example.org:34KJDCSKJN2HHF0DW20394", "displayName" : "Janey","name" : {"unstructured" : "Jane Doe"}, "gender" : "female"}

• JSON:

• XML:

Page 86: Google Devfest Bangkok - OpenSocial

86

RESTful and RPC protocolsREST responses (Person):

• AtomPub:

<entry xmlns="http://www.w3.org/2005/Atom"> <content type="application/xml"><person xmlns="http://ns.opensocial.org/2008/opensocial"> <name><unstructured>Jane Doe</unstructured> </name> <gender>female</gender></person> </content> <title/> <updated>2003-12-13T18:30:02Z</updated><author/> <id>urn:guid:example.org:34KJDCSKJN2HHF0DW20394</id></entry>

Page 87: Google Devfest Bangkok - OpenSocial

87

RESTful and RPC protocolsREST:•Perform operations using different HTTP methods on each URL.

CRUD:•Create•Retrieve•Update•Delete

HTTP:•POST•GET•PUT•DELETE

Page 88: Google Devfest Bangkok - OpenSocial

88

RESTful and RPC protocolsREST has some disadvantages:•Batch support requires multiple HTTP requests, or a contrived URLscheme.•Specifying multiple users via querystring is difficult. Is?uid=1234,5678 the same resource as ?uid=5678,1234 ?

Page 89: Google Devfest Bangkok - OpenSocial

89

RESTful and RPC protocolsRPC:•One endpoint - parameters specify methods to call.•Batch support.•Specify collections of users through passed arguments, not URLs.

POST /rpc HTTP/1.1Host:api.example.orgAuthorization: <Authtoken>Content-Type: application/json{"method" : "people.get", "id" : "myself""params" : { "userid" : "@me","groupid" : "@self" }}

Example - Fetch current user:• Request

HTTP/1.x 207 Multi-StatusContent-Type: application/json{ "id" :"myself" "result" : { "id" :"example.org:34KJDCSKJN2HHF0DW20394", "name" : {"unstructured" : "Jane Doe"}, "gender" : "female" }}

• Response

Page 90: Google Devfest Bangkok - OpenSocial

90

RESTful and RPC protocolsAuthentication:•Both protocols use OAuth to identify users and apps.•Depending on what the application needs to do, it can use two-leggedor three-legged OAuth.Two-legged OAuth:•The application authenticates directly with the container.•Perform non-user specific operations:

• Update persistent data for app users.• Can request information for users who have shared their profile

information with the app.Three-legged OAuth:•The user tells the container to give profile access to the application.•Perform user specific operations:

• Post activities.• Fetch friends of the current user.

Page 91: Google Devfest Bangkok - OpenSocial

91

RESTful and RPC protocolsClient libraries are being created for PHP, Java, and Python.•Help you connect to OpenSocial containers, and work with socialdata on your server.

Sample: log into a container:

Page 92: Google Devfest Bangkok - OpenSocial

92

RESTful and RPC protocols

92

RESTful and RPC use OAuth for authentication•OAuth is an open standard.•Client libraries will help make this process easier for developers.

Sample: use OAuth to get an access token for a user:

Page 93: Google Devfest Bangkok - OpenSocial

93

RESTful and RPC protocols•Once OAuth is used, you can store a user token for later access.

Sample: use an existing token:

Page 94: Google Devfest Bangkok - OpenSocial

94

RESTful and RPC protocols•Once authentication has happened, requests are easy:

Sample: Fetch the current user:

Page 95: Google Devfest Bangkok - OpenSocial

95

RESTful and RPC protocols

Sample: Fetch the current user’s friends:

Page 96: Google Devfest Bangkok - OpenSocial

9696

Development ModelsHow OpenSocial apps are built

Page 97: Google Devfest Bangkok - OpenSocial

9797

OpenSocial ToolsWhat sets us apart from the animals

Page 98: Google Devfest Bangkok - OpenSocial

98

ShindigWriting a gadget server is difficult:•Fast changing API - hard to keep up.•Standardization is hard to get right.•Costs ¥ / 元 !

Page 99: Google Devfest Bangkok - OpenSocial

99

ShindigApache Shindig to the rescue!•Open Source project.•Available in Java and PHP.•Run by itself and connect to anexisting social site to addOpenSocial support.•Goal: Launch anew (simple)container in underan hour’s worthof work

http://incubator.apache.org/shindig/

Page 100: Google Devfest Bangkok - OpenSocial

100

OpenSocial Dev AppDevelopment tool to test out JS code in different containers

http://osda.appspot.com

Page 101: Google Devfest Bangkok - OpenSocial

101101

Upcoming FeaturesCaja and Templates

Page 102: Google Devfest Bangkok - OpenSocial

102

CajaWhen JavaScript goes bad•Gadgets can be a new vector for phishing, spam, malware.Social spread ofgadgets can spread bad gadgets too.Caja reduces threats with a JavaScriptsanitizer as an additional "sandbox"on top of iFrame protection.

Page 103: Google Devfest Bangkok - OpenSocial

103

Caja

• A capability-based Javascript sanitizer.An Open Source project fromGoogle.Optional but recommended forOpenSocial containers.Will eventually be secure enoughto run gadgetsinline instead of in iframes.

Caja is:

http://code.google.com/p/google-caja/

Page 104: Google Devfest Bangkok - OpenSocial

104

TemplatesNeed for a templating language:•Developers need a simple way to convert OpenSocial data to HTML.•DOM manipulation is slow and ugly.•innerHTML is unsafe.

Page 105: Google Devfest Bangkok - OpenSocial

105

Templates

http://ostemplates-demo.appspot.com/

<script type="text/javascript" src="http://ostemplates-demo.appspot.com/ostemplates.js"></script> <scripttype="text/os-template"> <b>${owner.displayName}'s friends</b> <ul> <lirepeat="friends">${displayName}</li> </ul> </script> <script type="text/javascript"> function loadData() {var req = opensocial.newDataRequest(); req.add(req.newFetchPersonRequest('OWNER'), 'owner');var idSpecFriends = opensocial.newIdSpec( {'userId':'OWNER', 'groupId':'FRIENDS'});req.add(req.newFetchPeopleRequest(idSpecFriends), 'friends'); req.send(function(data) {os.Container.processDocument(data); }); } gadgets.util.registerOnLoadHandler(loadData); </script>

Page 106: Google Devfest Bangkok - OpenSocial

106

Templates

http://ostemplates-devapp.appspot.com/

Templates developer application available:

Page 107: Google Devfest Bangkok - OpenSocial

107107

The OpenSocial specification process“We can fix it, we have the technology”

Page 108: Google Devfest Bangkok - OpenSocial

108

The OpenSocial specification process

Page 109: Google Devfest Bangkok - OpenSocial

109

The OpenSocial specification process

Page 110: Google Devfest Bangkok - OpenSocial

110

The OpenSocial specification process

Page 111: Google Devfest Bangkok - OpenSocial

111

The OpenSocial specification process

Page 112: Google Devfest Bangkok - OpenSocial

112

The OpenSocial specification process

Page 113: Google Devfest Bangkok - OpenSocial

113113

ChallengesNobody said this was going to be easy

Page 114: Google Devfest Bangkok - OpenSocial

114

Challenges

This lumberjack willthank anyone who

helps solve thefollowing problems...

David Glazer, Director of Engineering, GoogleOpenSocial Foundation board member

Page 115: Google Devfest Bangkok - OpenSocial

115

ChallengesCross container development is still tricky:•Containers may not follow the standard.•Containers may follow the standard but have different policies.•Follow best practices:http://tinyurl.com/4nuzll

Page 116: Google Devfest Bangkok - OpenSocial

116

ChallengesNo central directory•Hard for apps to spread to many containers.•Apps need to work with different install processes.•Directory approval requirements vary from container to container.

Page 117: Google Devfest Bangkok - OpenSocial

117

ChallengesScaling is hard:•Easy to start and get some users.

Page 118: Google Devfest Bangkok - OpenSocial

118

ChallengesScaling is hard:•Being popular on one social networkcan push your server to the limit...

Page 119: Google Devfest Bangkok - OpenSocial

119119

Scaling is hard:•...being popular on many networkswill push you right over.

Page 120: Google Devfest Bangkok - OpenSocial

120120

Resources

Page 121: Google Devfest Bangkok - OpenSocial

121

Resources

• OpenSocial Tutorial: http://rurl.org/ss3

• OpenSocial Spec, Foundation, Reference: http://opensocial.org

• Caja: http://code.google.com/p/google-caja/

• Shindig: http://incubator.apache.org/shindig/

• OpenSocial Across Containers video: http://tinyurl.com/4nuzll

• OpenSocial Templates: http://ostemplates-demo.appspot.com/

• OpenSocial Dev App: http://osda.appspot.com

• Partuza: http://partuza.nl

• OpenSocial Specification Proposals:http://groups.google.com/group/opensocial-and-gadgets-spec/topics

121

Page 122: Google Devfest Bangkok - OpenSocial

122

OpenSocial Gadget Contest for Southeast Asia

• To support the developer community and encourageinnovation on the OpenSocial platform in SoutheastAsia

• Countries: Malaysia, Philippines, Singapore, Thailand,Vietnam

• 4 winners per country: Nintendo Wii, Apple iPod Touchprizes

• Judging panel: Google, eXo Platform, Friendster,Globant, hi5

• Dates:Registration opens: Nov 15, 2008Registration ends: Jan 10, 2009Winners notified: Jan 23, 2009Results announced: Feb 6, 2009

• The REAL reward for local developers: winning gadgetsto be promoted on OpenSocial partner websites topotentially reach hundreds of millions of Internet usersworldwide

• http://code.google.com/events/apacdevfest/contest

Page 123: Google Devfest Bangkok - OpenSocial

123

Learn morecode.google.com