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.
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.
The basics steps for getting started are:
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.
For more background on the OpenSocial APIs and how they relate to GFC, see:
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:
|
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:
|
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. |
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.