|
|
|
|
Advanced CustomizationsFrom $1Table of contents
This chapter discusses the following subjects: 4. Loading GS script Dynamically
Using Facebook ConnectGigya Socialize supports using the Facebook Connect user interface as the login mechanism or as a method for connecting users to their Facebook accounts.
Note: the Facebook Connect feature is not supported in ActionScript environment.
ImplementationTo start using Facebook Connect, please perform the following steps:
Note: If you use the Widget Setup Wizards to integrate Gigya Socialize's Widgets in your website, Facebook Connect will be displayed by default. The reason for this behavior is - since the code generated by the Widget Setup Wizards includes the useFacebookConnect parameter by default.
Custom Network IconsGigya socialize enables replacing the icons of the network buttons in the Login and Connect Widgets. The following is an example shows the Login Widget with both the MySpace and the Facebook icons replaced (see also running example below):
ImplementationTo implement, please follow these steps: Step 1 - Create a SWF file which contains your custom iconsAdobe Flash:
FlashDevelop:
Step 2 - Update the UI for the Login or Connect WidgetAdd the parameter SNButtonsURL to the params object which is passed to showLoginUI() or showConnectUI(). The parameter should be set with the URL of the SWF file that you created in step 1. For example:
gigya.services.socialize.showLoginUI(conf,{SNButtonsURL: 'http://wikifiles.gigya.com/Socialize/CustomButtons.swf' });
Last Logged-in IconsThe Login Widget give an indication of the last provider the user was logged into, so as to provide an improved user experience. The Widget will display the specific provider's icon first (the position will precede the rest of the icons) and will display an alternative highlighted icon. You may provide resources and specify your custom "Last Logged-in" highlighted icons: 1. Add your social network highlighted icons to the library as MovieClips. 2. For each social network highlighted icon - set the movie clip identifier to be: library.WFSIcons.SN.btn[Social-network-name].LastLogin. For example: library.WFSIcons.SN.btnFacebook.LastLogin, library.WFSIcons.SN.btnMyspace.LastLogin, etc.
Running Example:
The Example Code:
<html>
<head>
<!-- including the socialize.js script -->
<SCRIPT type="text/javascript" lang="javascript"
src="http://cdn.gigya.com/JS/socialize.js?apikey=2_Y82PzwJ_chSFImHXaIDJClnLyJzmk-VFOavSsaNTzl6m901s_NNxRAS0xJ3bd3_N">
</SCRIPT>
<script type="text/javascript">
var conf =
{
APIKey: "2_Y82PzwJ_chSFImHXaIDJClnLyJzmk-VFOavSsaNTzl6m901s_NNxRAS0xJ3bd3_N"
}
var params =
{
// set the SNButtonsURL parameter with the URL of the SWF file containing the alternative icons:
SNButtonsURL: 'http://wikifiles.gigya.com/Socialize/CustomButtons.swf'
}
</script>
</head>
<body>
<div id="loginDiv"></div>
<script type="text/javascript">
gigya.services.socialize.showLoginUI(conf, params);
</script>
</body>
</html>
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="383" height="269" applicationComplete="init()">
<mx:Canvas x="36" y="56" id="loginCanvas" width="325" height="200">
</mx:Canvas>
<mx:Script>
<![CDATA[
private var conf:Object = {
// gigya key
APIKey: '2_Y82PzwJ_chSFImHXaIDJClnLyJzmk-VFOavSsaNTzl6m901s_NNxRAS0xJ3bd3_N'
}
// This method is executed on applicationComplete
private function init():void {
// Initialize the "mcRoot" attribute of the conf object - should refer to the root of the flash container.
this.conf.mcRoot=this.root;
// Load socialize service
var loadParams:Object = {
services:'socialize',
callback:onGigyaInit
}
gigya.load(conf,loadParams);
}
// Wait for the load to complete and handle failures/success
private function onGigyaInit(response:*):void {
if (response.hadError) {
// handle failure
trace('An error has occurred while attempting to load Socialize service');
} else {
showLoginUI();
}
}
private function showLoginUI(): void {
// Define parameters object:
var params:Object =
{
// set the SNButtonsURL parameter with the URL of the SWF file containing the alternative icons.
SNButtonsURL: 'http://wikifiles.gigya.com/Socialize/CustomButtons.swf'
};
// Call the Socialize API method - showLoginUI:
gigya.services.socialize.showLoginUI(conf, params);
}
]]>
</mx:Script>
</mx:Application>
Note:
In order to make this code work in your environment, please:
The CustomButtons.swf SourceYou may download here the FLA containing the custom icons which we use in the running example (the source of CustomButtons.swf).
< Back to 'Server Side API' | Next to 'Loading GS Script Dynamically' >
Tags:
|
||||
|