时间:2011-04-18 12:49:35

标签: actionscript-3 internet-explorer actionscript facebook-graph-api

我正在尝试使用Facebook Actionscript图形api,但我似乎在IE中遇到了问题(其他浏览器如chrome和firefox到目前为止似乎都没问题。)

据我所知,它正在登录并返回用户ID但是当我使用Facebook.api(_user,handleUserRequest)查找该用户时;我收到了错误。

Facebook Actionscript图形api是否存在影响IE的任何已知问题?

感谢 OB

每个请求 - 错误如下:

[IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: https://graph.facebook.com/100002210990429?access%5Ftoken=205690086123032%7C2%2EUzvN3mFr07kPAecZ7qN1Rg%5F%5F%2E3600%2E1303135200%2E1%2D100002210990429%7Cz9L%5Fc26QKCc6cs2g5FClG%5FBsoZg"]

这个如果这个网址被粘贴到chrome中就可以了,但IE返回“无法从graph.facebook.com下载XXXXXXXX”

最好

奥比

我正在使用的代码如下:

package com.client.facebookgame.services 
{

    import com.client.facebookgame.services.events.FacebookServiceEvent;
    import com.facebook.graph.data.FacebookSession;
    import com.facebook.graph.Facebook;
    import flash.events.Event;
    import flash.events.EventDispatcher;
    import flash.events.TimerEvent;
    import flash.external.ExternalInterface;
    import flash.net.URLRequestMethod;
    import flash.utils.Timer;
    import uk.co.thereceptacle.utils.Debug;

    /**
     * Facebook Service
     */
    public class FacebookService extends EventDispatcher
    {
        // constants
        public static const API_KEY             : String = "XXXXXX";
        public static const PERMISSIONS         : String = "read_stream,publish_stream,user_likes";
        public static const FB_REDIRECT_URL     : String = "http://apps.facebook.com/appname/";
        public static const LOGGED_IN           : String = "loggedin";
        public static const LOGGED_IN_ON_FB     : String = "loggedinonfacebook";
        public static const LOGGED_OUT          : String = "loggedout";
        public static const LOGGED_OUT_ON_FB    : String = "loggedoutonfacebook";

        public static const TIMEOUT_COUNT       : int = 10;
        public static const TIMER_DELAY         : int = 3 * 1000;


        // properties
        private var _user           : String;
        private var _topUrl         : String;
        private var _currentState   : String;
        private var _timer          : Timer;
        private var _timerCount     : int;

        public var postObject       : Object;


        // constuctor
        public function FacebookService() 
        {
            if (ExternalInterface.available) _topUrl = ExternalInterface.call("top.location.toString");
            Debug.log("facebook init", this);
            Facebook.init(API_KEY, handleLogin);

            startTiming();

            currentState = _topUrl ? LOGGED_OUT : LOGGED_OUT_ON_FB;
        }




        // methods
        public function login():void
        {
            Facebook.login(handleLogin, { perms: PERMISSIONS } );
        }

        public function logout():void
        {
            Facebook.logout(handleLogout);
        }

        public function selectUserFriendsWithAppRequestDialogue(message:String, dialogueType:String = "iframe", optionalPostObject:Object = null):void
        {
            this.postObject = optionalPostObject;
            Facebook.ui("apprequests", { message:message }, handleAppRequest, dialogueType);
        }

        public function checkIfUserLikesApp():void
        {
            Facebook.api(_user + "/likes", handleLikes);
        }

        private function startTiming():void
        {
            if (_timer) clearTimer();
            _timer = new Timer(TIMER_DELAY, TIMEOUT_COUNT);
            _timer.addEventListener(TimerEvent.TIMER, handleTimerEvents);
            _timer.addEventListener(TimerEvent.TIMER_COMPLETE, handleTimerEvents);
            _timer.start();
        }

        private function clearTimer():void
        {
            _timer.stop();
            _timer.removeEventListener(TimerEvent.TIMER, handleTimerEvents);
            _timer.removeEventListener(TimerEvent.TIMER_COMPLETE, handleTimerEvents);
            _timer = null;

            _timerCount = 0;
        }

        // event handlers
        private function handleLogin(success:Object, fail:Object):void
        {
            if (_timer) clearTimer();

            if (success)
            {
                Debug.log(success, this);
                _user = success.uid;

                currentState = _topUrl ? LOGGED_IN : LOGGED_IN_ON_FB;

                Facebook.api("/" + _user, handleGetUser);
            }
            else if (!success && !_topUrl)
            {
                ExternalInterface.call("redirect", API_KEY, PERMISSIONS, FB_REDIRECT_URL);
            }
        }

        private function handleGetUser(success:Object, fail:Object):void
        {
            Debug.log(success + ", " + fail, this);
            if (success) dispatchEvent(new FacebookServiceEvent(FacebookServiceEvent.GET_USER_COMPLETE, success));
            else dispatchEvent(new FacebookServiceEvent(FacebookServiceEvent.GET_USER_FAIL, fail, true));
        }

        private function handleAppRequest(result:Object):void
        {
            if (postObject)
            {
                for (var i:int = 0; i < result.request_ids.length; i++)
                {
                    var requestID:String = result.request_ids[i];
                    Facebook.api("/" + requestID, handleRequestFriends); 
                }
            }
        }

        private function handleRequestFriends(success:Object, fail:Object):void
        {
            if (success)
            {
                var friendID:String = success.to.id;
                Facebook.api("/" + friendID + "/feed", handleSubmitFeed, postObject, URLRequestMethod.POST);
            }
            else
            {
                Debug.log(fail, this);
            }
        }

        private function handleLikes(success:Object, fail:Object):void
        {
            if (success)
            {
                for (var i:int = 0; i < success.length; i++)
                {

                    Debug.log("compare " + success[i].id  + " with key: " + API_KEY, this);
                    if (success[i].id == API_KEY)
                    {

                        Debug.log("found that user liked this app!!!", this, true);
                        dispatchEvent(new FacebookServiceEvent(FacebookServiceEvent.USER_LIKES_APP, { userLikesApp:true } ));
                        return;
                    }
                }

                dispatchEvent(new FacebookServiceEvent(FacebookServiceEvent.USER_LIKES_APP, { userLikesApp:false } ));
            }
            else
            {
                Debug.log(fail, this, true);
            }
        }

        private function handleLogout(obj:*):void
        {
            currentState = _topUrl ? LOGGED_OUT : LOGGED_OUT_ON_FB;
        }

        private function handleSubmitFeed(success:Object, fail:Object):void
        {
            if (success) dispatchEvent(new FacebookServiceEvent(FacebookServiceEvent.FEED_SUBMITTED, success));
            else dispatchEvent(new FacebookServiceEvent(FacebookServiceEvent.FEED_FAIL, fail, true));
        }

        private function handleTimerEvents(e:TimerEvent):void 
        {
            switch (e.type)
            {
                case TimerEvent.TIMER :
                    _timerCount ++;
                    Debug.log("facebook init attempt " + _timerCount, this);
                    Facebook.init(API_KEY, handleLogin);
                    break;

                case TimerEvent.TIMER_COMPLETE :
                    clearTimer();
                    dispatchEvent(new FacebookServiceEvent(FacebookServiceEvent.GET_USER_FAIL));
                    break;
            }
        }



        // accessors / mutators
        public function get currentState():String { return _currentState; }
        public function set currentState(value:String):void
        {
            if (_currentState != value)
            {
                _currentState = value;
                dispatchEvent(new FacebookServiceEvent(FacebookServiceEvent.STATE_UPDATE));
            }
        }

    }

}

非常感谢 OB

2 个答案:

答案 0 :(得分:1)

我在facebook actionscript问题列表中找到了答案: http://code.google.com/p/facebook-actionscript-api/issues/detail?id=197

  

我也在努力寻找解决方案   但唯一的一个是发布它   flash player 10

为我解决了问题

答案 1 :(得分:1)

我遇到了同样的问题。这个问题的主要原因是Flash Player版本。 使用 Flash Player 10 + FaceBookGraphApi SWC 文件与Flash Player 10兼容。 此解决方案仅适用于使用来自 GraphAPI_Examples_1_6_1

的swc的用户