简体   繁体   English

Facebook 使用flex4登录

[英]Facebook Login using flex4

I am trying to integrate my application with facebook.I followed the official tutorial on adobe http://www.adobe.com/devnet/facebook/articles/flex_fbgraph_pt3.html I get no errors or warnings.我正在尝试将我的应用程序与 facebook 集成。我遵循了 adobe 上的官方教程http://www.adobe.com/devnet/facebook/articles/flex_fbgraph_pt3.ZFC35FDC70D5FC69D253EZ83没有错误或警告7C. But when I run my app,on click upon login the login window does not pop up at all..as in nothing happens...No errors of any sort..但是当我运行我的应用程序时,在登录时单击登录 window 根本不会弹出......因为没有任何反应......没有任何错误......

CAn anyone tell me what s goinf wrong.Kindly point to some working tutorial谁能告诉我出了什么问题。请指出一些工作教程

Thanks!!谢谢!!

this is a way to connect to Facebook using Graph API.这是一种使用图形 API 连接到 Facebook 的方法。 Everything is explained in comment.一切都在评论中解释。 This is actually the connecting to facebook, no posting to walls or anything.这实际上是连接到 facebook,没有张贴到墙上或任何东西。 That part can be found below this class.该部分可以在此 class 下方找到。

package com.DAL 
{
    import com.facebook.graph.Facebook;
    import flash.events.Event;
    import com.facebook.graph.data.FacebookSession;
    import flash.events.EventDispatcher;
    import flash.events.MouseEvent;
    import com.fbLoginButton;
    import com.adobe.serialization.json.JSON;

    public class FBConnect extends EventDispatcher
    {
        /******************************************
        *   Variables
        ******************************************/
        private var _applicationID:String;
        private var _extendedPermissions:Object;

        /******************************************
        *   Constants
        ******************************************/
        public static const CONNECTED:String = "CONNECTED";

        /******************************************
        *   Properties
        ******************************************/             
        public function get ApplicationID():String
        {
            return _applicationID;
        }

        /******************************************
        *   Constructor
        ******************************************/
        public function FBConnect() 
        {
            super();

            //Set applicationid
            _applicationID = "YOUR_ID";

            //Set permissions to ask for
            _extendedPermissions = {perms:"read_stream, publish_stream, user_about_me, read_friendlists, user_photos"};

            //Initialize facebook
            Facebook.init(_applicationID);
        }

        /******************************************
        *   Methods
        ******************************************/     
        public function login(e:MouseEvent):void
        {           
            Facebook.login(handleLogin, _extendedPermissions);
        }

        private function handleLogin(response:Object, fail:Object):void
        {
            dispatchEvent(new Event(CONNECTED));
        }
    }
}

That should take care of connecting to facebook.这应该注意连接到 facebook。 If you want to post to walls or anything, you can find a small example below.如果你想张贴到墙上或任何东西上,你可以在下面找到一个小例子。

        /******************************************
        *   Constructor
        ******************************************/
        public function FBLogic() 
        {
            super();

            _connect = new FBConnect();
            _connect.addEventListener(FBConnect.CONNECTED, startLoaders);

            initLoaders();
        }

        /******************************************
        *   Methods
        ******************************************/

        ...

        public function post(message:String):void
        {
            var _params:Object = new Object();

            _params.access_token = Facebook.getSession().accessToken;
            _params.message = message;

            Facebook.api("/" + _userID + "/feed", messagePosted, _params, "POST");
        }

        public function messagePosted(response:Object, fail:Object):void
        {
            dispatchEvent(new Event(MESSAGEPOSTED));
        }

        public function login(e:MouseEvent):void
        {
            var _loginButton:fbLoginButton = e.target as fbLoginButton;
            _loginButton.alpha = 0;
            _loginButton.visible = false;

            _connect.login(e);
        }

If this doesn't do the trick you might have forgotten to add some code to your html file.如果这不能解决问题,您可能忘记在 html 文件中添加一些代码。 Be sure to add the following code to the head of your html file:请务必将以下代码添加到 html 文件的头部:

<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script> 

And you also need a div called fb-root, declared like this.你还需要一个名为 fb-root 的 div,声明如下。

<body>
    <div id="fb-root"></div>
    <div id="flashContent">
    </div>
</body>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM