My favorites | English | Sign in

Google Friend Connect APIs (Labs)

JS API

This document describes the Google Friend Connect (GFC) JavaScript API. You can use this API to add behavior to pages on GFC sites. Note that this API runs in the page, not inside of gadgets.

Contents

  1. Examples
  2. Basic Information
    1. OpenSocial API
    2. Google Friend Connect API
  3. Tutorial

Examples

You can integrate social data and activities from your GFC site's members using the JavaScript API and the OpenSocial REST/RPC protocol. This document focuses on the JavaScript API. For information about the REST and RPC protocols, see OpenSocial REST and RPC Protocol.

Basic information

The basics steps for getting started are:

  1. Create a GFC-enabled site via http://www.google.com/friendconnect.
  2. Paste the core GFC JavaScript API snippet into the site (see Setting up a website to use the inline Friend Connect library).
  3. Use GFC-specific API calls such as sign-in so that people can join the site.
  4. Use standard OpenSocial API calls to integrate social data from signed-in individuals and to generate activities that can be presented on your site and integrated social networks.

After you create a GFC-enabled site, click your site name to see a series of links to help you administer the site. GFC provides several gadgets to help site admins get started. For more information, see the GFC Help Center.

For a tutorial on how to use the Google Friend Connect JS API in your site, see the article In-page Integration of GFC JS API.

OpenSocial API

For more background on the OpenSocial APIs and how they relate to GFC, see:

Google Friend Connect API

The Google Friend Connect API lets webmasters and developers add behavior to Friend Connect site pages. You use these methods in the pages of a GFC site, not inside of gadgets.

However, some of these methods can still be useful to gadget developers in testing gadgets in a Friend Connect environment. For example, you can use them to disable gadget caching, or to pass information from the page into your gadget. For more discussion, see Gadgets for GFC.

The GFC API includes the following methods:

Method Description
google.friendconnect.container.initOpenSocialApi(params) Adds the OpenSocial JavaScript APIs directly into a Friend Connect website. The argument params is an object that accepts the following inputs:
  • site: (required) A string containing the site's ID.
  • onload: (optional) A callback function called every time the user's identity becomes known or changes.
google.friendconnect.renderSignInButton(params) Renders either a 'sign-in' or 'join' button branded with Google Friend Connect. You must use this method to render sign-in and join buttons. The argument params is an object that accepts the following inputs:
  • id: (required) A string containing the HTML element ID where the button will be rendered.
  • text: (optional) A string containing the text to display in the button. The default text is "Sign in with Google Friend Connect".
  • style: (optional) The button style, which can be one of standard, long, or text. The default is standard.
For more information about the buttons, see Google Friend Connect Buttons.
google.friendconnect.requestInvite(opt_message) Creates a pop-up box that allows the user to invite Friend Connect friends to become members of your Friend Connect website. Can optionally supply a value for opt_message to provide a custom message to replace the default message.
google.friendconnect.requestSettings() Creates a pop-up box that allows the user to manage his or her account and friends, or to unjoin your Friend Connect website.
google.friendconnect.requestSignIn() Creates a pop-up box that asks the user to sign-in to the Friend Connect website. When the sign-in process is complete, the onload handlers on the page are called again. Use of this method requires visible attribution of "Google Friend Connect" in proximity of the link.
google.friendconnect.requestSignOut() Logs the user out of the Friend Connect website and calls the onload handlers when done.
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.
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 more discussion and an example.
google.friendconnect.container.setParentUrl(url) Sets the url that is the location of rpc_relay.html and canvas.html. This function is only required if you are using canvas.html with the useLightBoxForCanvas option set.
google.friendconnect.newFetchInterestHintRequest() Creates an OpenSocial DataRequest for fetching keywords from the site profile to use as hints for ad networks, searches, or content management systems.

Tutorial

See the article In-page Integration of GFC JS API for a tutorial on how to use the Google Friend Connect JS API in your site.