Gigya 服务在 Flex4 中无法工作,但在 Flex3 中工作正常

发布于 2024-11-10 18:06:26 字数 7796 浏览 2 评论 0原文

我是 gigya 服务,使用社交服务登录来登录我的网页。

在我的 Flex 3 中一切都工作正常,但是自从我将代码更改为 Flex 4 后,我无法看到任何正在加载的 gigya 服务。

我的代码如下:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:flexlib_controls="flexlib.controls.*" 
                xmlns:s="library://ns.adobe.com/flex/spark" xmlns:fx="http://ns.adobe.com/mxml/2009"
                xmlns:mx="library://ns.adobe.com/flex/mx"
                verticalAlign="middle" horizontalAlign="center" width="400" height="150" layout="absolute"
                backgroundColor="#FFFFFF" borderStyle="none" color="#FFFFFF" backgroundGradientAlphas="[0,0]"
                backgroundAlpha="0" applicationComplete="init()"
                verticalScrollPolicy="off" horizontalScrollPolicy="off" fontFamily="Arial" fontSize="12">       

    <fx:Script>
        <![CDATA[                       
            import c7.config.ServerConfig;

            import com.adobe.serialization.json.JSON;
            import com.hurlant.crypto.*;
            import com.hurlant.crypto.hash.HMAC;
            import com.hurlant.crypto.symmetric.ICipher;
            import com.hurlant.util.Base64;
            import com.hurlant.util.Hex;

            import flash.net.navigateToURL;

            import mx.controls.Alert;
            import mx.core.Application;

            import mx.rpc.events.ResultEvent;

            import spark.components.supportClasses.ListBase;

            private var loginEventObj:Object = new Object();
            private var currentUID:String = new String();           
            private var userInfo:UserInfo = new UserInfo();
            public var currentResult:ByteArray;
            public var secretKey:String = ServerConfig.get_gigya_key().secret_key;          

            // Define a configuration object. Insert your APIKey below: 
            private var conf:Object = { 
                APIKey: ServerConfig.get_gigya_key().api_key 
            };


            [Bindable]
            private static var RPC_URL:String = ServerConfig.get_rpc_base_url();            

            [Bindable]
            private var system_message:String = null;

            private var newUserFlag:Boolean = true; // lets assume the user is new first.

            private function init():void
            {               
                initSocialService();
            }


            private function initSocialService():void
            {               
                Security.allowDomain("cdn.gigya.com");
                Security.allowInsecureDomain("cdn.gigya.com");

                // Initialize the "mcRoot" attribute of the conf object - should refer to the root of the flash container. 
                this.conf.mcRoot=this.root; 

                // Load Social service 
                // Create the load-parameters object 
                var loadParams:Object = { 
                    services:'socialize',
                    callback:onServiceInit 
                } 

                // Load the service 
                gigya.load(conf,loadParams);
            }

            // Wait for the load to complete and handle failures/success 
            private function onServiceInit(response:*):void 
            { 
                if (response.hadError)          
                    throw new Error('Failed to init gigya service');                
                else 
                { 
                    gigya.services.socialize.addEventHandlers(conf, {onLogin:onLoginHandler});
                    showLoginUI(); 
                } 
            } 

            private function showLoginUI():void 
            {               
                // Define parameters object: 
                var params:Object = {width: 350,
                    enabledProviders: "facebook, twitter, yahoo, messenger, google, linkedin, myspace, aol, openid",
                    height: 80,
                    lastLoginIndication: "welcome",                     
                    showTermsLink: false,
                    showWhatsThis: true,                        
                    hideGigyaLink: true,
                    container: loginCanvas, // embed component inside loginCanvas container
                    UIConfig: '<config><body><background frame-color="#BFBFBF" background-color="#FFFFFF" corner-roundness="5;5;5;5"></background></body></config>',
                    cid: 'login page'}; 
                gigya.services.socialize.showLoginUI(conf, params);
            }

            // Note: the actual signature calculation implementation should be on server side 
            private function verifyTheSignature(UID:String, timestamp:String, signature:String): void  
            { 
                //trace('Your user ID: ' + UID + '\n timestamp: ' + timestamp + '\n signature: ' + signature); 
            }                                                       
        ]]>
    </fx:Script>
    <fx:Style>
        .textInput{
            fontFamily: Arial; 
            color: #333333;                  
            fontSize: 14;
            paddingTop: 2;
            paddingBottom: 2;
            paddingRight: 2;
            paddingLeft: 2;
            cornerRadius: 5;
            borderStyle: solid;             
        }
        .smallText{
            fontSize: 10;
            fontFamily: Arial;
            color: #4483af;         
        }
    </fx:Style>
    <mx:ViewStack id="vs_main" width="100%" height="100%" top="0" left="0" borderStyle="none" paddingLeft="0" paddingTop="0" paddingRight="0"
                  paddingBottom="0" backgroundAlpha="0" creationPolicy="all" verticalScrollPolicy="off" horizontalScrollPolicy="off">
        <s:NavigatorContent id="bx_login"  width="100%" height="100%">
            <s:Group id="bx_login1" width="100%" height="100%">
                <s:Label id="both_required_error_lbl" text="Both username and password are required" top="2" left="2" color="#ff0000" visible="false"/>
                <s:Label id="invalid_error_lbl" text="{this.system_message}" top="2" left="2" color="#ff0000" visible="false"/>
                <flexlib_controls:PromptingTextInput prompt="username" width="150" maxChars="100" id="txt_username" top="22" left="2"
                                                     color="#000000" enter="authenticate(txt_username.text, txt_password.text)" styleName="textInput"/>
                <s:Label text="forgot username" styleName="smallText" useHandCursor="true" mouseChildren="false" buttonMode="true"
                         click="{vs_main.selectedChild= bx_forgot_username;}" top="49" left="2"/>
                <flexlib_controls:PromptingTextInput prompt="password" width="150" maxChars="100" id="txt_password"  styleName="textInput" top="22" left="160"
                                                     color="#000000" displayAsPassword="true" enter="authenticate(txt_username.text, txt_password.text)"/>
                <s:Label text="forgot password" styleName="smallText" useHandCursor="true" mouseChildren="false" buttonMode="true" left="160" top="49"
                         click="{vs_main.selectedChild=bx_forgot_password;}"/>          
                <s:Button id="btn_login" label="Submit" click="authenticate(txt_username.text, txt_password.text)" fontFamily="Arial" fontSize="12"
                          toolTip="Login using your existing account" color="#000000" top="22" right="2"/>
                <s:Group id="loginCanvas" height="80" width="100%" left="2" bottom="2"/>
            </s:Group>  
        </s:NavigatorContent>       
    </mx:ViewStack>
</mx:Application>

有人可以帮我解决这个问题吗?

问候 泽山

I was gigya service to login to my webpage using social services login.

Everything was working fine in my flex 3, but when since I have changed my code to flex 4, I am unable to see any gigya services being loaded.

My code is below:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:flexlib_controls="flexlib.controls.*" 
                xmlns:s="library://ns.adobe.com/flex/spark" xmlns:fx="http://ns.adobe.com/mxml/2009"
                xmlns:mx="library://ns.adobe.com/flex/mx"
                verticalAlign="middle" horizontalAlign="center" width="400" height="150" layout="absolute"
                backgroundColor="#FFFFFF" borderStyle="none" color="#FFFFFF" backgroundGradientAlphas="[0,0]"
                backgroundAlpha="0" applicationComplete="init()"
                verticalScrollPolicy="off" horizontalScrollPolicy="off" fontFamily="Arial" fontSize="12">       

    <fx:Script>
        <![CDATA[                       
            import c7.config.ServerConfig;

            import com.adobe.serialization.json.JSON;
            import com.hurlant.crypto.*;
            import com.hurlant.crypto.hash.HMAC;
            import com.hurlant.crypto.symmetric.ICipher;
            import com.hurlant.util.Base64;
            import com.hurlant.util.Hex;

            import flash.net.navigateToURL;

            import mx.controls.Alert;
            import mx.core.Application;

            import mx.rpc.events.ResultEvent;

            import spark.components.supportClasses.ListBase;

            private var loginEventObj:Object = new Object();
            private var currentUID:String = new String();           
            private var userInfo:UserInfo = new UserInfo();
            public var currentResult:ByteArray;
            public var secretKey:String = ServerConfig.get_gigya_key().secret_key;          

            // Define a configuration object. Insert your APIKey below: 
            private var conf:Object = { 
                APIKey: ServerConfig.get_gigya_key().api_key 
            };


            [Bindable]
            private static var RPC_URL:String = ServerConfig.get_rpc_base_url();            

            [Bindable]
            private var system_message:String = null;

            private var newUserFlag:Boolean = true; // lets assume the user is new first.

            private function init():void
            {               
                initSocialService();
            }


            private function initSocialService():void
            {               
                Security.allowDomain("cdn.gigya.com");
                Security.allowInsecureDomain("cdn.gigya.com");

                // Initialize the "mcRoot" attribute of the conf object - should refer to the root of the flash container. 
                this.conf.mcRoot=this.root; 

                // Load Social service 
                // Create the load-parameters object 
                var loadParams:Object = { 
                    services:'socialize',
                    callback:onServiceInit 
                } 

                // Load the service 
                gigya.load(conf,loadParams);
            }

            // Wait for the load to complete and handle failures/success 
            private function onServiceInit(response:*):void 
            { 
                if (response.hadError)          
                    throw new Error('Failed to init gigya service');                
                else 
                { 
                    gigya.services.socialize.addEventHandlers(conf, {onLogin:onLoginHandler});
                    showLoginUI(); 
                } 
            } 

            private function showLoginUI():void 
            {               
                // Define parameters object: 
                var params:Object = {width: 350,
                    enabledProviders: "facebook, twitter, yahoo, messenger, google, linkedin, myspace, aol, openid",
                    height: 80,
                    lastLoginIndication: "welcome",                     
                    showTermsLink: false,
                    showWhatsThis: true,                        
                    hideGigyaLink: true,
                    container: loginCanvas, // embed component inside loginCanvas container
                    UIConfig: '<config><body><background frame-color="#BFBFBF" background-color="#FFFFFF" corner-roundness="5;5;5;5"></background></body></config>',
                    cid: 'login page'}; 
                gigya.services.socialize.showLoginUI(conf, params);
            }

            // Note: the actual signature calculation implementation should be on server side 
            private function verifyTheSignature(UID:String, timestamp:String, signature:String): void  
            { 
                //trace('Your user ID: ' + UID + '\n timestamp: ' + timestamp + '\n signature: ' + signature); 
            }                                                       
        ]]>
    </fx:Script>
    <fx:Style>
        .textInput{
            fontFamily: Arial; 
            color: #333333;                  
            fontSize: 14;
            paddingTop: 2;
            paddingBottom: 2;
            paddingRight: 2;
            paddingLeft: 2;
            cornerRadius: 5;
            borderStyle: solid;             
        }
        .smallText{
            fontSize: 10;
            fontFamily: Arial;
            color: #4483af;         
        }
    </fx:Style>
    <mx:ViewStack id="vs_main" width="100%" height="100%" top="0" left="0" borderStyle="none" paddingLeft="0" paddingTop="0" paddingRight="0"
                  paddingBottom="0" backgroundAlpha="0" creationPolicy="all" verticalScrollPolicy="off" horizontalScrollPolicy="off">
        <s:NavigatorContent id="bx_login"  width="100%" height="100%">
            <s:Group id="bx_login1" width="100%" height="100%">
                <s:Label id="both_required_error_lbl" text="Both username and password are required" top="2" left="2" color="#ff0000" visible="false"/>
                <s:Label id="invalid_error_lbl" text="{this.system_message}" top="2" left="2" color="#ff0000" visible="false"/>
                <flexlib_controls:PromptingTextInput prompt="username" width="150" maxChars="100" id="txt_username" top="22" left="2"
                                                     color="#000000" enter="authenticate(txt_username.text, txt_password.text)" styleName="textInput"/>
                <s:Label text="forgot username" styleName="smallText" useHandCursor="true" mouseChildren="false" buttonMode="true"
                         click="{vs_main.selectedChild= bx_forgot_username;}" top="49" left="2"/>
                <flexlib_controls:PromptingTextInput prompt="password" width="150" maxChars="100" id="txt_password"  styleName="textInput" top="22" left="160"
                                                     color="#000000" displayAsPassword="true" enter="authenticate(txt_username.text, txt_password.text)"/>
                <s:Label text="forgot password" styleName="smallText" useHandCursor="true" mouseChildren="false" buttonMode="true" left="160" top="49"
                         click="{vs_main.selectedChild=bx_forgot_password;}"/>          
                <s:Button id="btn_login" label="Submit" click="authenticate(txt_username.text, txt_password.text)" fontFamily="Arial" fontSize="12"
                          toolTip="Login using your existing account" color="#000000" top="22" right="2"/>
                <s:Group id="loginCanvas" height="80" width="100%" left="2" bottom="2"/>
            </s:Group>  
        </s:NavigatorContent>       
    </mx:ViewStack>
</mx:Application>

Can someone plz help me with this issue.

Regards
Zeeshan

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

高冷爸爸 2024-11-17 18:06:26

由于 Spark 组件,Gigaya 服务无法运行。我不知道为什么 Spark s:Group 不支持 gigya,但如果我保留 flex3 mx:Canvas 组件来完成这项工作,它就可以完美工作。

The Gigaya Service was not working because of the Spark component. I dont have the reason why spark s:Group is not supporting gigya, but if I keep the flex3 mx:Canvas component to do the job, it works perfectly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文