Lesson 01: A simple HelloWorld

From VZ Developer Wiki
Jump to: navigation, search

General Guidelines | XML Specification | Features | Views | JavaScript API | REST API | Tutorials | OAuth

Back to overview Lesson 02: Meta data and how it's used

Gadget basics

At their core, social gadgets are XML files, sometimes known as gadget specifications. Here is a simple "Hello World" gadget (helloworld.xml), that illustrates the basic sections of a specification:

<?xml version="1.0" encoding="UTF-8" ?>
   <ModulePrefs title="Hello World!">
     <Require feature="opensocial-0.8" />
   <Content type="html">
       Hello, world!

In the "Hello World" example, you can see several sections which control the features and design of the gadget.

  • <Module> indicates that this XML file contains a gadget.
  • <ModulePrefs> contains information about the gadget, and its author.
  • <Require feature="opensocial-0.8" /> denotes a required feature of the gadget — in this case, the OpenSocial API (v0.8).
  • <Content type="html"> indicates that the gadget's content type is HTML. This is the recommended content type for OpenSocial containers, but gadgets for other containers such as iGoogle support other content types.
  • <![ CDATA[…]]> contains the bulk of the gadget, including all of the HTML, CSS, and JavaScript (or references to such files). The content of this section should be treated like the content of the body tag on a generic HTML page.

Uploading the gadget to the VZ Gadget Sandbox

The Gadget Sandbox is available at studiVZ and meinVZ only. At first you have to upgrade your VZ account to a developer account at our developer portal (http://www.meinvz.net/Developer or http://www.studivz.net/Developer). After a short review of your submission by our Developer Support, you will recieve a confirmation E-Mail that your account has been upgraded.

Now you can create an Gadget and Upload your Hello World Gadget as a new Gadget Revision. You can find more information on our Sandbox at Sandbox_Overview.

Note that each revision you upload consists of a ZIP package with at least the gadget XML file inside (the xml filename has to be the same as the ZIP file name), but you can include as much static content (CSS, JavaScript, Flash, Images, ..) as you like. The whole package will be pushed to our CDN at deployment (see Lesson 05: Fetching content from VZ CDN).

  • Lesson 01: A simple HelloWorld