SlideShare una empresa de Scribd logo
1 de 14
OPENSOCIAL
     CODELAB

PIETER DE SCHEPPER
Web Developer - Netlog

JOCHEN DELABIE
Web Developer - Netlog


CHEWY TREWHELLA
Developer Advocate - Google
Getting Started



• Text Editor or Google Gadget Editor
• Web Hosting or built-in hosting from Google
  Gadget Editor
• You need a Netlog Account
• You can start developing in the Netlog
  Sandbox
Netlog Sandbox

http://en.netlog.com/go/developer/opensocial/
sandbox
Gadget Basics


Hello World example
<?xml version=quot;1.0quot; encoding=quot;UTF-8quot; ?>
<Module>
	 <ModulePrefs title=quot;Hello Worldquot; author=quot;Pieter De
Schepperquot; author_email=quot;pieter@netlog.comquot;>
	 	 <Require feature=quot;opensocial-0.8quot;/>
	 </ModulePrefs>
	 <Content type=quot;htmlquot;>
	 	 <![CDATA[
	 	 	 Hello World!
	 	 ]]>
	 </Content>
</Module>
Gadget Basics

•    <Module>   implies that the XML describes a gadget
•    <ModulePrefs>contains information about the
     gadget, its author and its basic characteristics
•                                   specifies to the
     <Require feature=quot;opensocial-0.8quot;/>

     container to load a certain feature, in this case
     opensocial 0.8
•                       indicates that the gadget’s
     <Content type=quot;htmlquot;>

     content type is html
•                contains all HTML, CSS, JavaScript
     <![CDATA[...]]

     that makes the gadget to what it is
Writing your first Social Gadget



Request Friends of viewer
function loadFriends()
{
	   var req = opensocial.newDataRequest();
	   req.add(req.newFetchPersonRequest(opensocial.IdSpec.PersonId.VIEWER), 'viewer');
	   	    	   	   	
	   var viewerFriends = opensocial.newIdSpec({ quot;userIdquot; : quot;VIEWERquot;, quot;groupIdquot; : quot;FRIENDSquot; });
	   var opt_params = {};
	   opt_params[opensocial.DataRequest.PeopleRequestFields.MAX] = 100;
	   req.add(req.newFetchPeopleRequest(viewerFriends, opt_params), 'viewerFriends');
	   	    	   	   	
	   req.send(onLoadFriends);
}

function init()
{
	   loadFriends();
}
	   	    	   	
gadgets.util.registerOnLoadHandler(init);
Writing your first Social Gadget



Handling the data
function onLoadFriends(data)
{
	    var viewer = data.get('viewer').getData();
	    var viewerFriends = data.get('viewerFriends').getData();
	
	    var html = new Array();
	    html.push('Friends of ' + viewer.getDisplayName());
   	 html.push('<ul>');
   	 viewerFriends.each(function(person)
   	 {
   	 	   if (person.getId())
   	 	   {
   	 	   	    html.push('<li>' + person.getDisplayName() + quot;</li>quot;);
  	 	    }
   	 });
   	 html.push('</ul>');
   	 document.getElementById('friends').innerHTML = html.join('');
}
Using App Data



Saving App Data
function saveScore(score)
{
	   var req = opensocial.newDataRequest();
	   req.add(req.newUpdatePersonAppDataRequest(quot;VIEWERquot;, 'score', score));
	   req.send(onSaveScore);
}

function onSaveScore(data)
{
	   if(!data.hadError())
	   {
	   	    alert(quot;Score saved!quot;);
	   }
}
Using App Data



Retrieving App Data
function getScore()
{
	   var req = opensocial.newDataRequest();
	   var viewer = opensocial.newIdSpec({ quot;userIdquot; : quot;VIEWERquot; });
	   req.add(req.newFetchPersonRequest(quot;VIEWERquot;), 'viewer');
	   req.add(req.newFetchPersonAppDataRequest(viewer, 'score'), 'data');
	   req.send(onGetScore);
}

function onGetScore(data)
{
	   var viewer = data.get('viewer').getData();
	   var data = data.get('data').getData();
	   document.getElementById('score').innerHTML = quot;Your current score is quot; +
	   	    data[viewer.getId()]['score'];
}
Creating activity



Creating activity
function createActivity(score)
{
	   var activityParams = {};
	   activityParams[opensocial.Activity.Field.TITLE] = quot;got a new highscore!quot;;
	   activityParams[opensocial.Activity.Field.BODY] = quot;The score was quot; + score;

	   var activity = opensocial.newActivity(activityParams);
	   opensocial.requestCreateActivity(activity, opensocial.CreateActivityPriority.HIGH,
onCreateActivity);
}

function onCreateActivity(data)
{
	   if(!data.hadError())
	   {
	   	    alert(quot;Activity created!quot;);
	   }
}
Sending notifications



Sending notifications
function sendNotification(toUserID, fromName)
{
	   var recipients = [toUserID];
	   var msg = fromName + quot; has challenged you to a game of pokerquot;;
	   var params = {};
	   params[opensocial.Message.Field.TYPE] = opensocial.Message.Type.NOTIFICATION;
	   var message = opensocial.newMessage(msg, params);
	   opensocial.requestSendMessage(recipients, message);
}
Making use of views


<?xml version=quot;1.0quot; encoding=quot;UTF-8quot; ?>
<Module>
	   <ModulePrefs title=quot;Viewsquot; author=quot;Pieter De Schepperquot; author_email=quot;pieter@netlog.comquot;>
	   	    <Require feature=quot;opensocial-0.8quot;/>
	   	    <Require feature=quot;viewsquot;/>
	   </ModulePrefs>
	   <Content type=quot;htmlquot; view=quot;canvasquot;>
	   	    <![CDATA[
	   	    Hello Canvas!<br/>
	   	    <a href=quot;#quot; onclick=quot;gadgets.views.requestNavigateTo('profile')quot;>To profile view</a>
	   	    ]]>
	   </Content>
	   <Content type=quot;htmlquot; view=quot;profilequot;>
	   	    <![CDATA[
	   	    Hello Profile!<br/>
	   	    <a href=quot;#quot; onclick=quot;gadgets.views.requestNavigateTo('canvas')quot;>To canvas view</a>
	   	    ]]>
	   </Content>
</Module>
Other features



• Content requests
• requestShareApp
• Dynamic height
• Netlog extensions
Usefull links


•   Netlog OpenSocial
    http://en.netlog.com/go/developer/opensocial

•   Netlog Sandbox
    http://en.netlog.com/go/developer/opensocial/sandbox

•   OpenSocial reference
    http://code.google.com/apis/opensocial/docs/index.html

•   Gadget reference
    http://code.google.com/apis/gadgets/devguide_landing.html

•   OpenSocial Tutorial
    http://wiki.opensocial.org/index.php?title=OpenSocial_Tutorial

Más contenido relacionado

La actualidad más candente

OpenSocial Intro
OpenSocial IntroOpenSocial Intro
OpenSocial IntroPamela Fox
 
jQuery Presentation to Rails Developers
jQuery Presentation to Rails DevelopersjQuery Presentation to Rails Developers
jQuery Presentation to Rails DevelopersYehuda Katz
 
Taking Web Apps Offline
Taking Web Apps OfflineTaking Web Apps Offline
Taking Web Apps OfflinePedro Morais
 
Java script programs
Java script programsJava script programs
Java script programsITz_1
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2fishwarter
 
5 Reasons To Love CodeIgniter
5 Reasons To Love CodeIgniter5 Reasons To Love CodeIgniter
5 Reasons To Love CodeIgniternicdev
 
AngularJS Introduction
AngularJS IntroductionAngularJS Introduction
AngularJS IntroductionBrajesh Yadav
 
Web Projects: From Theory To Practice
Web Projects: From Theory To PracticeWeb Projects: From Theory To Practice
Web Projects: From Theory To PracticeSergey Bolshchikov
 
Boston Computing Review - Ruby on Rails
Boston Computing Review - Ruby on RailsBoston Computing Review - Ruby on Rails
Boston Computing Review - Ruby on RailsJohn Brunswick
 
Rails GUI Development with Ext JS
Rails GUI Development with Ext JSRails GUI Development with Ext JS
Rails GUI Development with Ext JSMartin Rehfeld
 
Web Automation Testing Using Selenium
Web Automation Testing Using SeleniumWeb Automation Testing Using Selenium
Web Automation Testing Using SeleniumPete Chen
 
Jaoo - Open Social A Standard For The Social Web
Jaoo - Open Social A Standard For The Social WebJaoo - Open Social A Standard For The Social Web
Jaoo - Open Social A Standard For The Social WebPatrick Chanezon
 
Local SQLite Database with Node for beginners
Local SQLite Database with Node for beginnersLocal SQLite Database with Node for beginners
Local SQLite Database with Node for beginnersLaurence Svekis ✔
 
Speed is a feature PyConAr 2014
Speed is a feature PyConAr 2014Speed is a feature PyConAr 2014
Speed is a feature PyConAr 2014Pablo Mouzo
 
Shaping up with angular JS
Shaping up with angular JSShaping up with angular JS
Shaping up with angular JSBrajesh Yadav
 

La actualidad más candente (20)

OpenSocial Intro
OpenSocial IntroOpenSocial Intro
OpenSocial Intro
 
jQuery Presentation to Rails Developers
jQuery Presentation to Rails DevelopersjQuery Presentation to Rails Developers
jQuery Presentation to Rails Developers
 
22 j query1
22 j query122 j query1
22 j query1
 
Taking Web Apps Offline
Taking Web Apps OfflineTaking Web Apps Offline
Taking Web Apps Offline
 
Java script programs
Java script programsJava script programs
Java script programs
 
Why Django for Web Development
Why Django for Web DevelopmentWhy Django for Web Development
Why Django for Web Development
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2
 
jQuery basics
jQuery basicsjQuery basics
jQuery basics
 
5 Reasons To Love CodeIgniter
5 Reasons To Love CodeIgniter5 Reasons To Love CodeIgniter
5 Reasons To Love CodeIgniter
 
AngularJS Introduction
AngularJS IntroductionAngularJS Introduction
AngularJS Introduction
 
Soa lab 3
Soa lab 3Soa lab 3
Soa lab 3
 
JavaScript Training
JavaScript TrainingJavaScript Training
JavaScript Training
 
Web Projects: From Theory To Practice
Web Projects: From Theory To PracticeWeb Projects: From Theory To Practice
Web Projects: From Theory To Practice
 
Boston Computing Review - Ruby on Rails
Boston Computing Review - Ruby on RailsBoston Computing Review - Ruby on Rails
Boston Computing Review - Ruby on Rails
 
Rails GUI Development with Ext JS
Rails GUI Development with Ext JSRails GUI Development with Ext JS
Rails GUI Development with Ext JS
 
Web Automation Testing Using Selenium
Web Automation Testing Using SeleniumWeb Automation Testing Using Selenium
Web Automation Testing Using Selenium
 
Jaoo - Open Social A Standard For The Social Web
Jaoo - Open Social A Standard For The Social WebJaoo - Open Social A Standard For The Social Web
Jaoo - Open Social A Standard For The Social Web
 
Local SQLite Database with Node for beginners
Local SQLite Database with Node for beginnersLocal SQLite Database with Node for beginners
Local SQLite Database with Node for beginners
 
Speed is a feature PyConAr 2014
Speed is a feature PyConAr 2014Speed is a feature PyConAr 2014
Speed is a feature PyConAr 2014
 
Shaping up with angular JS
Shaping up with angular JSShaping up with angular JS
Shaping up with angular JS
 

Similar a OpenSocial CodeLab - Building Social Gadgets for Netlog

Open Selector
Open SelectorOpen Selector
Open Selectorjjdelc
 
Google Devfest Singapore - OpenSocial
Google Devfest Singapore - OpenSocialGoogle Devfest Singapore - OpenSocial
Google Devfest Singapore - OpenSocialPatrick Chanezon
 
Developing and testing ajax components
Developing and testing ajax componentsDeveloping and testing ajax components
Developing and testing ajax componentsIgnacio Coloma
 
Javascript: Ajax & DOM Manipulation v1.2
Javascript: Ajax & DOM Manipulation v1.2Javascript: Ajax & DOM Manipulation v1.2
Javascript: Ajax & DOM Manipulation v1.2borkweb
 
Intro Open Social and Dashboards
Intro Open Social and DashboardsIntro Open Social and Dashboards
Intro Open Social and DashboardsAtlassian
 
OpenSocial - GTUG Stockholm Meeting Oct 1 2009
OpenSocial - GTUG Stockholm Meeting Oct 1 2009OpenSocial - GTUG Stockholm Meeting Oct 1 2009
OpenSocial - GTUG Stockholm Meeting Oct 1 2009Jacob Gyllenstierna
 
Rugalytics | Ruby Manor Nov 2008
Rugalytics | Ruby Manor Nov 2008Rugalytics | Ruby Manor Nov 2008
Rugalytics | Ruby Manor Nov 2008Rob
 
Building Web Interface On Rails
Building Web Interface On RailsBuilding Web Interface On Rails
Building Web Interface On RailsWen-Tien Chang
 
Django - Framework web para perfeccionistas com prazos
Django - Framework web para perfeccionistas com prazosDjango - Framework web para perfeccionistas com prazos
Django - Framework web para perfeccionistas com prazosIgor Sobreira
 
Hi5 Opensocial Code Lab Presentation
Hi5 Opensocial Code Lab PresentationHi5 Opensocial Code Lab Presentation
Hi5 Opensocial Code Lab Presentationplindner
 
Migration testing framework
Migration testing frameworkMigration testing framework
Migration testing frameworkIndicThreads
 
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)Carles Farré
 
ActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group PresentationActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group Presentationipolevoy
 
Plone Interactivity
Plone InteractivityPlone Interactivity
Plone InteractivityEric Steele
 
Gadgets Intro (Plus Mapplets)
Gadgets Intro (Plus Mapplets)Gadgets Intro (Plus Mapplets)
Gadgets Intro (Plus Mapplets)Pamela Fox
 
IBM Lotus Notes Domino XPages and XPages for Mobile
IBM Lotus Notes Domino XPages and XPages for MobileIBM Lotus Notes Domino XPages and XPages for Mobile
IBM Lotus Notes Domino XPages and XPages for MobileChris Toohey
 
Client-side JavaScript Vulnerabilities
Client-side JavaScript VulnerabilitiesClient-side JavaScript Vulnerabilities
Client-side JavaScript VulnerabilitiesOry Segal
 

Similar a OpenSocial CodeLab - Building Social Gadgets for Netlog (20)

Open Selector
Open SelectorOpen Selector
Open Selector
 
Google Devfest Singapore - OpenSocial
Google Devfest Singapore - OpenSocialGoogle Devfest Singapore - OpenSocial
Google Devfest Singapore - OpenSocial
 
Developing and testing ajax components
Developing and testing ajax componentsDeveloping and testing ajax components
Developing and testing ajax components
 
Javascript: Ajax & DOM Manipulation v1.2
Javascript: Ajax & DOM Manipulation v1.2Javascript: Ajax & DOM Manipulation v1.2
Javascript: Ajax & DOM Manipulation v1.2
 
Intro Open Social and Dashboards
Intro Open Social and DashboardsIntro Open Social and Dashboards
Intro Open Social and Dashboards
 
OpenSocial - GTUG Stockholm Meeting Oct 1 2009
OpenSocial - GTUG Stockholm Meeting Oct 1 2009OpenSocial - GTUG Stockholm Meeting Oct 1 2009
OpenSocial - GTUG Stockholm Meeting Oct 1 2009
 
Rugalytics | Ruby Manor Nov 2008
Rugalytics | Ruby Manor Nov 2008Rugalytics | Ruby Manor Nov 2008
Rugalytics | Ruby Manor Nov 2008
 
Building Web Interface On Rails
Building Web Interface On RailsBuilding Web Interface On Rails
Building Web Interface On Rails
 
Django - Framework web para perfeccionistas com prazos
Django - Framework web para perfeccionistas com prazosDjango - Framework web para perfeccionistas com prazos
Django - Framework web para perfeccionistas com prazos
 
Hi5 Opensocial Code Lab Presentation
Hi5 Opensocial Code Lab PresentationHi5 Opensocial Code Lab Presentation
Hi5 Opensocial Code Lab Presentation
 
Migration testing framework
Migration testing frameworkMigration testing framework
Migration testing framework
 
Ajax ons2
Ajax ons2Ajax ons2
Ajax ons2
 
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)
 
ActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group PresentationActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group Presentation
 
Grails and Dojo
Grails and DojoGrails and Dojo
Grails and Dojo
 
Plone Interactivity
Plone InteractivityPlone Interactivity
Plone Interactivity
 
Gadgets Intro (Plus Mapplets)
Gadgets Intro (Plus Mapplets)Gadgets Intro (Plus Mapplets)
Gadgets Intro (Plus Mapplets)
 
Web Scraping with PHP
Web Scraping with PHPWeb Scraping with PHP
Web Scraping with PHP
 
IBM Lotus Notes Domino XPages and XPages for Mobile
IBM Lotus Notes Domino XPages and XPages for MobileIBM Lotus Notes Domino XPages and XPages for Mobile
IBM Lotus Notes Domino XPages and XPages for Mobile
 
Client-side JavaScript Vulnerabilities
Client-side JavaScript VulnerabilitiesClient-side JavaScript Vulnerabilities
Client-side JavaScript Vulnerabilities
 

Último

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Último (20)

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

OpenSocial CodeLab - Building Social Gadgets for Netlog

  • 1. OPENSOCIAL CODELAB PIETER DE SCHEPPER Web Developer - Netlog JOCHEN DELABIE Web Developer - Netlog CHEWY TREWHELLA Developer Advocate - Google
  • 2. Getting Started • Text Editor or Google Gadget Editor • Web Hosting or built-in hosting from Google Gadget Editor • You need a Netlog Account • You can start developing in the Netlog Sandbox
  • 4. Gadget Basics Hello World example <?xml version=quot;1.0quot; encoding=quot;UTF-8quot; ?> <Module> <ModulePrefs title=quot;Hello Worldquot; author=quot;Pieter De Schepperquot; author_email=quot;pieter@netlog.comquot;> <Require feature=quot;opensocial-0.8quot;/> </ModulePrefs> <Content type=quot;htmlquot;> <![CDATA[ Hello World! ]]> </Content> </Module>
  • 5. Gadget Basics • <Module> implies that the XML describes a gadget • <ModulePrefs>contains information about the gadget, its author and its basic characteristics • specifies to the <Require feature=quot;opensocial-0.8quot;/> container to load a certain feature, in this case opensocial 0.8 • indicates that the gadget’s <Content type=quot;htmlquot;> content type is html • contains all HTML, CSS, JavaScript <![CDATA[...]] that makes the gadget to what it is
  • 6. Writing your first Social Gadget Request Friends of viewer function loadFriends() { var req = opensocial.newDataRequest(); req.add(req.newFetchPersonRequest(opensocial.IdSpec.PersonId.VIEWER), 'viewer'); var viewerFriends = opensocial.newIdSpec({ quot;userIdquot; : quot;VIEWERquot;, quot;groupIdquot; : quot;FRIENDSquot; }); var opt_params = {}; opt_params[opensocial.DataRequest.PeopleRequestFields.MAX] = 100; req.add(req.newFetchPeopleRequest(viewerFriends, opt_params), 'viewerFriends'); req.send(onLoadFriends); } function init() { loadFriends(); } gadgets.util.registerOnLoadHandler(init);
  • 7. Writing your first Social Gadget Handling the data function onLoadFriends(data) { var viewer = data.get('viewer').getData(); var viewerFriends = data.get('viewerFriends').getData(); var html = new Array(); html.push('Friends of ' + viewer.getDisplayName()); html.push('<ul>'); viewerFriends.each(function(person) { if (person.getId()) { html.push('<li>' + person.getDisplayName() + quot;</li>quot;); } }); html.push('</ul>'); document.getElementById('friends').innerHTML = html.join(''); }
  • 8. Using App Data Saving App Data function saveScore(score) { var req = opensocial.newDataRequest(); req.add(req.newUpdatePersonAppDataRequest(quot;VIEWERquot;, 'score', score)); req.send(onSaveScore); } function onSaveScore(data) { if(!data.hadError()) { alert(quot;Score saved!quot;); } }
  • 9. Using App Data Retrieving App Data function getScore() { var req = opensocial.newDataRequest(); var viewer = opensocial.newIdSpec({ quot;userIdquot; : quot;VIEWERquot; }); req.add(req.newFetchPersonRequest(quot;VIEWERquot;), 'viewer'); req.add(req.newFetchPersonAppDataRequest(viewer, 'score'), 'data'); req.send(onGetScore); } function onGetScore(data) { var viewer = data.get('viewer').getData(); var data = data.get('data').getData(); document.getElementById('score').innerHTML = quot;Your current score is quot; + data[viewer.getId()]['score']; }
  • 10. Creating activity Creating activity function createActivity(score) { var activityParams = {}; activityParams[opensocial.Activity.Field.TITLE] = quot;got a new highscore!quot;; activityParams[opensocial.Activity.Field.BODY] = quot;The score was quot; + score; var activity = opensocial.newActivity(activityParams); opensocial.requestCreateActivity(activity, opensocial.CreateActivityPriority.HIGH, onCreateActivity); } function onCreateActivity(data) { if(!data.hadError()) { alert(quot;Activity created!quot;); } }
  • 11. Sending notifications Sending notifications function sendNotification(toUserID, fromName) { var recipients = [toUserID]; var msg = fromName + quot; has challenged you to a game of pokerquot;; var params = {}; params[opensocial.Message.Field.TYPE] = opensocial.Message.Type.NOTIFICATION; var message = opensocial.newMessage(msg, params); opensocial.requestSendMessage(recipients, message); }
  • 12. Making use of views <?xml version=quot;1.0quot; encoding=quot;UTF-8quot; ?> <Module> <ModulePrefs title=quot;Viewsquot; author=quot;Pieter De Schepperquot; author_email=quot;pieter@netlog.comquot;> <Require feature=quot;opensocial-0.8quot;/> <Require feature=quot;viewsquot;/> </ModulePrefs> <Content type=quot;htmlquot; view=quot;canvasquot;> <![CDATA[ Hello Canvas!<br/> <a href=quot;#quot; onclick=quot;gadgets.views.requestNavigateTo('profile')quot;>To profile view</a> ]]> </Content> <Content type=quot;htmlquot; view=quot;profilequot;> <![CDATA[ Hello Profile!<br/> <a href=quot;#quot; onclick=quot;gadgets.views.requestNavigateTo('canvas')quot;>To canvas view</a> ]]> </Content> </Module>
  • 13. Other features • Content requests • requestShareApp • Dynamic height • Netlog extensions
  • 14. Usefull links • Netlog OpenSocial http://en.netlog.com/go/developer/opensocial • Netlog Sandbox http://en.netlog.com/go/developer/opensocial/sandbox • OpenSocial reference http://code.google.com/apis/opensocial/docs/index.html • Gadget reference http://code.google.com/apis/gadgets/devguide_landing.html • OpenSocial Tutorial http://wiki.opensocial.org/index.php?title=OpenSocial_Tutorial

Notas del editor