52
A Technical Overview Chris Schalk, Google Developer Advocate Jiwoong Lee, Web developer Seoul - 11/18/2008

Open Social Summit Korea Overview

  • View
    4.459

  • Download
    1

Embed Size (px)

DESCRIPTION

An overview presentation on OpenSocial technology

Citation preview

Page 1: Open Social Summit Korea Overview

A Technical Overview

Chris Schalk, Google Developer Advocate

Jiwoong Lee, Web developer

Seoul - 11/18/2008

Page 2: Open Social Summit Korea Overview

2

Agenda

• OpenSocial History & Concepts

• Building OpenSocial Applications

• Hosting OpenSocial Applications

• OpenSocial Updates

• The OpenSocial Specification Process

Page 3: Open Social Summit Korea Overview

3 3

The OpenSocial History & Concepts

Page 4: Open Social Summit Korea Overview

4

OpenSocial Roadmap

• Version 0.5 was released in a “developer release” on Nov1st.

• First “sandbox” was made available on Orkut

• Version 0.6 was released in December• Initial version of Shindig server software was launched as Apacheincubator project• Other sandboxes came live - Hi5, Ning, Plaxo …

• Version 0.7 (production) was released in January• MySpace, Hi5, Orkut began running 0.7

Page 5: Open Social Summit Korea Overview

5

OpenSocial Roadmap

• Version v0.8 (0.8.1) is current

• Latest evolution of OpenSocial as defined by theOpenSocial development community

• Updated JavaScript API• Now contains a RESTful protocol, RPC protocol

• hi5, MySpace, orkut, iGoogle now support 0.8

• Specification:http://www.opensocial.org/Technical-Resources/opensocial-spec-v081

Page 6: Open Social Summit Korea Overview

6

OpenSocial 0.9 - Coming Soon!

• Goal:

– Enable a faster development experience that is both secure andefficient

Core principles:

• Client-side and server-side processing

• Standard set of tags with extensibility model

– Example: <os:ShowPerson>

• More 0.9 later….

Page 7: Open Social Summit Korea Overview

7

OpenSocial Concepts - What is a Container?

An OpenSocial “Container” is a website that can hostOpenSocial applications

• Is an SNS that supports OpenSocial• Can serve Gadgets/OpenSocial Applications• Provides end user social experience• Provides access to site’s social graph through applications

Page 8: Open Social Summit Korea Overview

8

OpenSocial Concepts - What is an Application?

An “OpenSocial Application” is a gadget that uses socialfeatures

• OpenSocial applications are gadgets that support the OpenSocialJavaScript APIs• Similar to traditional gadget

• Encapsulated in an XML document• Container fetches XML document, parses content, serves renderedHTML/JS/CSS content in an iFrame

• OpenSocial applications can rely on third party services

Page 9: Open Social Summit Korea Overview

9 9

Building OpenSocial Applications

Page 10: Open Social Summit Korea Overview

10

Gadgets Basics

A 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 11: Open Social Summit Korea Overview

11

A gadget server:

•Takes the gadget spec as input.

•Performs optimizations on the gadget spec.

•Outputs HTML, JavaScript, and CSS as one document.

Gadgets Basics

Page 12: Open Social Summit Korea Overview

12

Gadgets Basics

A container:

•Displays the social network’s user interface.

•Opens an IFrame to the rendered gadget.

Containers and gadget servers are both run by the social network, but do not need to be on the same machine, or even domain.

Page 13: Open Social Summit Korea Overview

13

Gadgets Basics

Example 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 14: Open Social Summit Korea Overview

14

Gadgets Basics

Page 15: Open Social Summit Korea Overview

15

Making Gadgets Social

OpenSocial API has three core services:

•People & Friends• Access friends information programmatically

•Activities• See what you’re friends are up to• Share what you are doing

•Persistence• Provide state without a server• Share data with your friends

Gadgets can become social with OpenSocial JavaScript API

Page 16: Open Social Summit Korea Overview

16

Integrating OpenSocial applications with external servers

• What if you need to store more data than yourcontainer allows?

• Solution: You can make independent requests outto external servers.• Use: gadgets.io.makeRequest

• Can also make authenticated requests using Oauth

• Can use cloud services from: Joyent, Amazon orAppEngine!

The OpenSocial persistence service provides a way to store/share small amounts of data on the OpenSocialserver, but…

Page 17: Open Social Summit Korea Overview

17

Integrating OpenSocial applications with external servers

An example request to an external server

browser

OpenSocialServer

1. Initial request made from gadget2. Server routes request to external server

ExternalServer

gadgets.io.makeRequest

1 2

Requests can be secured using OAuth

Page 18: Open Social Summit Korea Overview

18

Advanced OpenSocial App Development

Arne will provide more detailed coverage on OpenSocialApplication Development at 3:00pm!

Page 19: Open Social Summit Korea Overview

19

Demonstration

• Building simple OpenSocial Client Applications

Page 20: Open Social Summit Korea Overview

20 20

Hosting OpenSocial Applications

Page 21: Open Social Summit Korea Overview

21

How to host OpenSocial Applications

1. Can build your own server that implementsOpenSocial specification…

2. Or can use “Shindig” - Reference implementation forOpenSocial

Page 22: Open Social Summit Korea Overview

22

Hosting OpenSocial Applications

What is Shindig?

• Gadget Server

–Parses gadget XML, renders as HTML/JS/CSS

• OpenSocial Data Server

–Includes RESTful API server

• Container JavaScript

–Core gadgets, OpenSocial JavaScript environment

http://incubator.apache.org/shindig

Page 23: Open Social Summit Korea Overview

23 23

How Shindig works

• Gadget Server

• OpenSocial Data Server

Yoursite.com

Gadget

GadgetServer

OpenSocialDataServer

Shindig

Page 24: Open Social Summit Korea Overview

24

Why use Shindig?

• Strong Open Source community

• High quality production-ready code

• Synchronized with specification

• Language neutral (Java, PHP, …)

Page 25: Open Social Summit Korea Overview

25

Shindig success at hi5

• Big Traffic

• 10k req/sec Edge

• 6k req/sec Origin

• Hundreds of Developers

• 1800+ Apps

• 1 Billion hits/day

… on 42 Shindig servers

25

Page 26: Open Social Summit Korea Overview

26

Demonstration: Trying out Shindig

26

Page 27: Open Social Summit Korea Overview

27

Adapting Shindig

• Adapting Shindig to your own social data

Gadget Server

OpenSocialDataServer

Shindig

ActivityService

PersonService

AppDataService

Social GraphData

Page 28: Open Social Summit Korea Overview

28

Demonstration: Shindig with MySQL

28

Page 29: Open Social Summit Korea Overview

29

RESTful and RPC protocols

Opens new development models

• Background processing.

• Easier Flash integration.

• Mobile applications.

Page 30: Open Social Summit Korea Overview

30

Communication methods:

•RESTful (Representational State Transfer)

•RPC (Remote Procedure Call) ‏

Formats:

•XML

•JSON

•AtomPub

RESTful and RPC protocols

Page 31: Open Social Summit Korea Overview

31

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 32: Open Social Summit Korea Overview

32

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 33: Open Social Summit Korea Overview

33

<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 34: Open Social Summit Korea Overview

34

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 35: Open Social Summit Korea Overview

35

RESTful and RPC protocols

REST has some disadvantages:

•Batch support requires multiple HTTP requests, or a contrived URL

scheme.

•Specifying multiple users via querystring is difficult. Is

?uid=1234,5678 the same resource as ?uid=5678,1234 ?

Page 36: Open Social Summit Korea Overview

36

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: <Auth token>Content-Type: application/json{ "method" : "people.get", "id" : "myself", "params" : { "userid" : "@me", "groupid" : "@self" }}

Example - Fetch current user:

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

• Response

Page 37: Open Social Summit Korea Overview

37

RESTful and RPC protocols

Client libraries are being created for PHP, Java, and Python.

• Help you connect to OpenSocial containers, and work with social

data on your server.

Sample: log into a container:

Page 38: Open Social Summit Korea Overview

38

RESTful and RPC protocols

Sample: Fetch the current user’s friends:

Page 39: Open Social Summit Korea Overview

39

RESTful and RPC protocols

39

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 40: Open Social Summit Korea Overview

40

OpenSocial RESTful/RPC and Mobile

Page 41: Open Social Summit Korea Overview

41

Demonstration: Trying out the RESTful protocol

41

String uid = "05047698136432048591";

OpenSocialClient client = new OpenSocialClient("orkut.com");

client.setProperty(OpenSocialClient.Property.RESTFUL_BASE_URI, "http://orkut.com/social/rest/");client.setProperty(OpenSocialClient.Property.TOKEN, "hpelsWNlP2SN8zkJiW6qBawcfxw");client.setProperty(OpenSocialClient.Property.SHARED_SECRET, "AounHfbA8JLJxhMmAFCoffTK");

try { Person p; OpenSocialObject d;

p = client.fetchPerson(uid); System.out.println("Display name: " + p.getDisplayName() + "¥n");

Collection<Person> c = client.fetchFriends(uid); for (Person friend : c) { System.out.println(friend.getDisplayName() + " - " + friend.getId()); }}

Page 42: Open Social Summit Korea Overview

42 42

OpenSocial Future Updates - 0.9

Page 43: Open Social Summit Korea Overview

43

What’s coming in OpenSocial 0.9

• HTML on your own Server

• OpenSocial Templates

• Other stuff..

• http://wiki.opensocial.org/index.php?title=Spec_Changes

Page 44: Open Social Summit Korea Overview

44

Dynamic HTML from your own server

<Content href="http://developer.com/canvas">

<os:PeopleRequest userId="@viewer" groupId="@friends"

fields="name,birthday" key="ViewerFriends">

</Content>

Example PHP:

<?php

// Code here will pull POST param into $ViewerFriends

echo "<h1>Welcome to the birthday app</h1>";

foreach ($ViewerFriends as $friend) {

if ($friend['birthday']) {

echo "<div>".$friend['name']."'s birthday is".

$friend['birthday']"</div>";

}

}

?>

Example gadget XML:

Page 45: Open Social Summit Korea Overview

45

Using OpenSocial Templates

<Content type="html">

<h1>Welcome to the birthday app!</h1>

<script type="text/os-template">

<os:PeopleRequest userId="@viewer" groupId="@friends"

fields="name,birthday" key="friends">

<div repeat="${friends}">

${Name}'s birthday is ${Birthday}

</div>

</script>

</Content>

Example gadget XML:

Page 46: Open Social Summit Korea Overview

46

Demonstration: Trying out OS Templates

46

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

Page 47: Open Social Summit Korea Overview

47 47

The OpenSocial specification process

Page 48: Open Social Summit Korea Overview

48

The OpenSocial specification process

Page 49: Open Social Summit Korea Overview

49

The OpenSocial specification process

Page 50: Open Social Summit Korea Overview

50

The OpenSocial specification process

Page 51: Open Social Summit Korea Overview

51

Useful Links

New Wiki! (Compliancy, Cross container development …)• http://wiki.opensocial.org

Homepage & specification:• http://www.opensocial.org

Get on the forums:• http://groups.google.com/group/opensocial

Subscribe to the Shindig mailing list:• [email protected]

Help shape the specification:• http://groups.google.com/group/opensocial-and-gadgets-spec/

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

OS Templates:• http://groups.google.com/group/opensocial-and-gadgets-spec/web/opensocial-templates

Page 52: Open Social Summit Korea Overview

52

Questions

Q&A