OpenSocial gadget developers have new audience - the millions of sites that are already GFC-enabled, and are thus OpenSocial containers. Here are a few examples of OpenSocial gadgets that have been tuned for Google Friend Connect:


There are a variety of ways to take advantage of GFC as a gadget developer:
This document describes how to develop gadgets to run effectively in Friend Connect. If you are new to OpenSocial and gadgets, see For more information for a list of documents you can read as an introduction.
Google Friend Connect supports the OpenSocial 0.9 specification for gadgets.
This document focuses on what you need to know to write a OpenSocial gadget that works well in a GFC site. GFC sites have a few differences from traditional social networks such as hi5 or orkut:
If you prefer to do the bulk of your programming server-side rather than in JavaScript, see OpenSocial REST/RPC Protocol.
Google Friend Connect supports OpenSocial Specification v0.9 for gadget development. This version added a number of important features for gadget developers to improve the gadget development process and the performance of their gadgets. These features include OSML, templates, proxied content, data pipelining and more.
For authentication, Friend Connect uses the RSA_SHA1 signature method (as defined in the OAuth standard) and the following public key, presented here as a self-signed certificate that should be easy to import into OAuth libraries. For more discussion of this topic, see the articles Introduction to Signed Requests and Validating Signed Requests.
http://www.google.com/friendconnect/certs/friendconnect.pem.
-----BEGIN CERTIFICATE----- MIICSjCCAbOgAwIBAgIJAKy5FQe8xeW/MA0GCSqGSIb3DQEBBQUAMCMxITAfBgNV BAMTGGZyaWVuZGNvbm5lY3QuZ29vZ2xlLmNvbTAeFw0wODEyMTkxOTQ3NDlaFw0w OTEyMTkxOTQ3NDlaMCMxITAfBgNVBAMTGGZyaWVuZGNvbm5lY3QuZ29vZ2xlLmNv bTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAvvHLRIP0tKwFGExqfIOf25Ad 2WHq/Oz4CuuspA75pvXg5+w9E4P5oMNmGNENO7LAA+xSrXLND+FdDg4STH/5FW0Y ycPhw7LvqsefQwnntn1oHGTYffWRPbovHZBDcCBJZ2cgzXnmsXG9D7rO06fikTaa 6aSw1mVt7sFvwZDegEkCAwEAAaOBhTCBgjAdBgNVHQ4EFgQUITh3OCFLiiyTPEsq LKmuALCpfXwwUwYDVR0jBEwwSoAUITh3OCFLiiyTPEsqLKmuALCpfXyhJ6QlMCMx ITAfBgNVBAMTGGZyaWVuZGNvbm5lY3QuZ29vZ2xlLmNvbYIJAKy5FQe8xeW/MAwG A1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAvnVl15uganMvEwABVxRwMAys ICPuzrxvdgAHXDl1/FCv68CEbTatHYPHBTLiY66DL8HICWwFuIx4j0DTuj6IWHRG iP2BFvtcRvogURixojA+JXsvIjafoShzqAioDptVUx1aIHM+af3B5zE6+wDVmRUz 1WeG3BvhoqPq1pUdWig= -----END CERTIFICATE-----
The GFC JavaScript API provides the following methods specifically applicable to gadget developers:
google.friendconnect.container.setNoCache(val) |
Lets you toggle whether a gadget is cached (the default) or not cached.
Turning off caching can be useful during the development process. To
disable caching, specify a value of 1 for val. See Disabling gadget caching for an example. |
google.friendconnect.container.renderOpenSocialGadget(params) |
Renders an OpenSocial gadget on the Friend Connect page. Takes an array of params that includes site id (site), gadget url (url), and view-params. The view-params array lets developers specify custom view parameters. See Passing data into a Friend Connect gadget for more discussion and an example. If you have a customized canvas.html file, and would prefer to use that instead of the Lightbox for canvas mode, you can set the useLightBoxForCanvas option to false. |
To disable gadget caching, add the following line to the portion of the snippet (which you copied from the Friend Connect gadget set up page) that renders your gadget:
google.friendconnect.
For example:
<script type="text/javascript"> google.friendconnect.container.setNoCache(1); google.friendconnect.container. renderOpenSocialGadget( { 'id': 'div-1234xxxxxx297', 'url':'http://gadget-doc- examples.googlecode.com/svn/ ', 'site': '05532xxxxxx509606791' }); </script>trunk/igoogle-profile-08.xml
To pass data into a Friend Connect gadget, use view-params. For example:
google.friendconnect.container. renderOpenSocialGadget( { id: 'div-1231709480881', url:'http://www.google.com/ friendconnect/gadgets/ ', 'view-params': { 'name':'value'}, site: '10563088438957768212'}, skin);lamegame.xml
Inside the gadget you can get the value as follows:
var params = gadgets.views.getParams(); var value = params['name'];
To use this technique, include <Require feature="views" /> in the
ModulePrefs of your XML gadget spec.
Each of the millions of the sites which use Google Friend Connect have their own color palettes. When designing and developing a gadget for Google Friend Connect, you should ensure that you allow the gadget to integrate well within all types of websites, whether they have white, black, or purple backgrounds and text.
At the time a site administrator installs a gadget, they can set the colors they want to use for that gadget, so the gadget integrates well with the style of the site. These colors are passed to the gadgets using the OpenSocial Gadgets.skins API.
Skin properties available for GFC gadgets:
| Property | Description |
|---|---|
BORDER_COLOR | Color of border of gadget, or 'transparent' if no border desired. |
CONTENT_BG_COLOR (0.8: BG_COLOR) | Background color to use for main portion of gadget. |
CONTENT_LINK_COLOR (0.8: ANCHOR_COLOR) | Color of unvisited links in the main portion of gadget. |
CONTENT_TEXT_COLOR (0.8: FONT_COLOR) | Color of primary or most-displayed text in main portion of gadget. |
CONTENT_HEADLINE_COLOR | Text color for titles or headlines as opposed to body text. Defaults to CONTENT_TEXT_COLOR. |
CONTENT_SECONDARY_TEXT_COLOR | An alternative color for secondary text that complements CONTENT_TEXT_COLOR; defaults to CONTENT_TEXT_COLOR. |
CONTENT_SECONDARY_LINK_COLOR | Color for links in secondary text; defaults to CONTENT_LINK_COLOR. |
ENDCAP_BG_COLOR | Color for top and bottom cap sections for the gadget; defaults to CONTENT_BG_COLOR. |
ENDCAP_LINK_COLOR | Color for links within top / bottom cap sections; defaults to CONTENT_LINK_COLOR. |
ENDCAP_TEXT_COLOR | Color for text within top / bottom cap sections; defaults to CONTENT_TEXT_COLOR. |
ALTERNATE_BG_COLOR | Used for alternating rows in large list; defaults to CONTENT_BG_COLOR. |
CONTENT_VISITED_LINK_COLOR | Visited link color; defaults to CONTENT_LINK_COLOR. |
In your gadget, you can use these properties by declaring the skins feature:
<Optional feature="skins"/>
Next, you can set the colors of your gadget using JavaScript:
$("someElement").style.borderColor = gadgets.skins.getProperty('BORDER_COLOR');
For more information on OpenSocial skins, see the gadgets.skins API reference.
Google Friend Connect uses the gadgets.Prefs functionality to define and configure preferences for a gadget. All preferences are defined in the XML gadgets specification, and site administrators are asked to provide the values for the preferences at the time they install the gadget on their site. More information on the XML definition for these preferences is available in the OpenSocial XML Reference.
Another popular use for Friend Connect is to create a standalone site for your OpenSocial gadget. To do this, pick a domain, and configure the site for Friend Connect in the usual way:
http://' prefix. Edit the div sizes accordingly - you may want to use 100% width instead of a fixed-size div, and you probably have a better idea of the height than the default, so you can avoid odd resizing when the gadget loads.If you want to submit your gadget for inclusion in the Google Friend Connect Gadgets Gallery, follow the instructions on the gadgets submission page.
For more information on OpenSocial and gadgets, see the following: