open social phpcamp

19
Pravin Nirmal OpenSocial Creating Orkut Applications

Upload: amit-kumar-singh

Post on 21-Jan-2015

1.339 views

Category:

Technology


0 download

DESCRIPTION

opensocial talk given by pravin nirmal in phpcamp

TRANSCRIPT

Page 1: Open Social Phpcamp

Pravin Nirmal

OpenSocialCreating Orkut Applications

Page 2: Open Social Phpcamp

Pravin Nirmal

Before We Start…

• If you have any questions, please don't hesitate to ask.

• During presentation we will create a sample application and run at Orkut.

• This session is not about OpenSocial container/Shindig.

Page 3: Open Social Phpcamp

Pravin Nirmal

About Me

• Doing PHP since 2000.

• Service Delivery Manager

@ Clarion Technologies Pvt. Ltd.

CMMI Level 3 Company

• My application “Cities I visited” listed at Orkut directory.

Page 4: Open Social Phpcamp

Pravin Nirmal

Something about you…

• How many of you know OpenSocial?

• How many of you used Facebook Applications?

• How many of you used Orkut Applications?.

Page 5: Open Social Phpcamp

Pravin Nirmal

Why OpenSocial?

• Facebook has its own API. It became popular with launch of applications.

• There are many other networking sites like Orkut, MySpace, hi5, linkedin etc.

• What if all creates their own API? Developer will have to create different application for each platform.

Page 6: Open Social Phpcamp

Pravin Nirmal

What an idea…

Page 7: Open Social Phpcamp

Pravin Nirmal

What is OpenSocial?

OpenSocial defines a common API for social applications across multiple websites. Built from standard JavaScript and HTML, developers can create apps with OpenSocial

that access a social network's

friends and update feeds.

Page 8: Open Social Phpcamp

Pravin Nirmal

Journey of OpenSocial

• Launched on November 1, 2007 with initial version 0.5

• Initially supported by Friendster, hi5, MySpace, Ning, orkut and many more.

• At launch Flixster, FotoFlexer, iLike, Newsgator, RockYou, Slide, Theikos, and VirtualTourist presented applications.

• Current version 0.8 released on May 28, 2008.

Page 9: Open Social Phpcamp

Pravin Nirmal

Who all are using it.

Page 10: Open Social Phpcamp

Pravin Nirmal

Basics…

Simple “Hello World” Application (helloworld.xml)

<?xml version="1.0" encoding="UTF-8" ?>

<Module>

<ModulePrefs title="Hello World!">

<Require feature="opensocial-0.8" />

</ModulePrefs>

<Content type="html">

<![CDATA[ Hello, world!]]>

</Content>

</Module>

Page 11: Open Social Phpcamp

Pravin Nirmal

Listing Friends …1 - xml

<?xml version="1.0" encoding="UTF-8"?>

<Module>

<ModulePrefs title=“PHPCamp- List Friends">

<Require feature="opensocial-0.7"/>

</ModulePrefs>

<Content type="html">

<![CDATA[ <script type="text/javascript"> /* ... */ </script>

<div id='main'>

Your friends: <div id='friends'></div>

</div>

]]> </Content> </Module>

Page 12: Open Social Phpcamp

Pravin Nirmal

Listing Friends … 2- js

<script language=“JavaScript”>

gadgets.util.registerOnLoadHandler(init);

function init() {

var req = opensocial.newDataRequest();

var opt_params = {};

opt_params[opensocial.DataRequest.PeopleRequestFields.MAX] = 20;

req.add(req.newFetchPeopleRequest('OWNER_FRIENDS',opt_params), 'ownerFriends');

req.send(onLoadFriends);

}

</script>

Page 13: Open Social Phpcamp

Pravin Nirmal

Listing Friends … 3- js

function onLoadFriends(data) {

var viewerFriends = data.get('viewerFriends').getData();

var html="";

html='<ul>';

viewerFriends.each(function(person) {

var friend_thumbnail = person.getField(opensocial.Person.Field.THUMBNAIL_URL);

html +='<li>' + person.getDisplayName() + '<img src="'+friend_thumbnail+'"> </li>';

});

html +='</ul>';

document.getElementById('friends').innerHTML = html;

}

Page 14: Open Social Phpcamp

Pravin Nirmal

Listing Friends … 4- output

Page 15: Open Social Phpcamp

Pravin Nirmal

What else you can do• Send request to your server and return information in

text,XML or JSON format.

• Insert activity in users updates.

• Use of AJAX.

• Store information at Orkut server.

• Fetch owner and his friends information.

Page 16: Open Social Phpcamp

Pravin Nirmal

What you can’t do• Post scraps through your application.

• Fetch personal information like phone number, birth date etc.

• Communicate between different OpenSocial sites.

• Any change at Orkut site. Application runs only at the space allocated to it e.g. profile view and container view.

• Run exactly same application on all supported sites.

Page 17: Open Social Phpcamp

Pravin Nirmal

References…• Orkut OpenSocial Blog http://orkut-open-social.blogspot.com/

• Orkut Developer Forum http://groups.google.com/group/opensocial-orkut

• Orkut developer Guide http://code.google.com/apis/orkut/docs/orkutdevguide.html

• OpenSocial Tutorial http://code.google.com/apis/opensocial/articles/tutorial/tutorial-0.8.html

Page 18: Open Social Phpcamp

Pravin Nirmal

That’s it!• If you have any questions, don't hesitate to ask.

• Demonstration scripts and forms can be seen under

http://www.myphpdunia.com/phpcamp.html

• Feel free to contact me at [email protected]

Page 19: Open Social Phpcamp

Pravin Nirmal

Thanks a lot for your interest.