"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
RIAction Social Applications in the Cloud 20090226
1. Gadgets and Social Applications
With OpenSocial
Vinoaj Vijeyakumaar
Customer Solutions Engineer
Google Southeast Asia
http://friendfeed.com/vinoaj
1
Google Confidential and Proprietary
21. First Stop
OpenSocial.org
Also a social network (surprise surprise!)
21
22. A day in the life of a social app developer
22
23. A day in the life of a social app developer
23
24. A day in the life of a social app developer
24
25. A day in the life of a social app developer
25
26. A day in the life of a social app developer
26
27. Gadgets
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.
27
28. Gadgets
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=quot;1.0quot; encoding=quot;UTF-8quot; ?>
<Module>
<ModulePrefs title=quot;Hello World!quot;>
<Require feature=quot;dynamic-heightquot; />
</ModulePrefs>
<Content type=quot;htmlquot;>
<![CDATA[
<h1>Hello World</h1>
<style type=quot;text/cssquot;>
h1 { color: #dd0000; }
</style>
<script type=quot;text/javascriptquot;>
gadgets.window.adjustHeight();
</script> ]]> </Content></Module>
28
29. Gadgets
JavaScript 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.
29
30. 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=quot;1.0quot; encoding=quot;UTF-8quot; ?>
<Module>
<ModulePrefs title=quot;Hello World!quot;>
<Require feature=quot;dynamic-heightquot; />
</ModulePrefs>
<Content type=quot;htmlquot;>
<![CDATA[ ... ]]>
</Content>
</Module>
30
31. Gadgets
<?xml version=quot;1.0quot; encoding=quot;UTF-8quot; ?>
<Module>
<ModulePrefs title=quot;Hello Social!quot;>
<Require feature=quot;opensocial-0.8quot; />
</ModulePrefs>
<Content type=quot;htmlquot;>
<![CDATA[ ... ]]>
</Content>
</Module>
The OpenSocial JavaScript API is a gadget feature, too!
31
37. The OpenSocial JavaScript API
Working with people:
• A Collection represents many opensocial.Person objects.
37
38. The OpenSocial JavaScript API
Working 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.
38
39. The OpenSocial JavaScript API
Working 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
39
40. The OpenSocial JavaScript API
Post 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.
40
42. RESTful and RPC protocols
Opens new development models
•Background processing.
•Easier Flash integration.
•Mobile applications.
42
43. RESTful and RPC protocols
Communication methods:
• RESTful (Representational State Transfer)
• RPC (Remote Procedure Call)
Formats:
• XML
• JSON
• AtomPub
43
44. RESTful and RPC protocols
REST:
• Resources are URLs.
Example - People:
• All people connected to the given user:
/people/{guid}/@all
• All friends of the given user:
/people/{guid}/@friends
• Profile of the given user:
/people/{guid}/@self
• Profile of the authenticated user:
/people/@me/@self
• Supported Person fields:
/people/@supportedFields
44
47. RESTful and RPC protocols
Authentication:
• Both protocols use OAuth to identify users and apps.
• Depending on what the application needs to do, it can use two-legged
or three-legged OAuth.
47
49. Shindig
Writing a gadget server is difficult:
• Fast changing API - hard to keep up.
• Standardization is hard to get right.
• Costs $ / ¥ / 元 !
49
56. Challenges
Cross 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
56
57. Challenges
No 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.
57