kennylerma / facebook-actionscript-api

Automatically exported from code.google.com/p/facebook-actionscript-api
0 stars 0 forks source link

FacebookMobile.logout () not working (FB has changed their mobile logout methods) #314

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Facebook has dramatically altered the way in which their mobile/touch 
login/logout process is handled.  This completely breaks just about everything 
the way it is currently setup in this library.  I have altered this code 
numerous times to try and stay "one step ahead of Mark" however, now I am at a 
loss.

Used to be (2 days ago) I could spawn a StageWebView window with the url:

http://m.facebook.com/logout.php and once it completed have the user logged out 
successfully.

Now the logout.php request is requiring three new variables:

http://m.facebook.com/logout.php?h=edae72809451927fdc0e5c6f3981d477&t=1307157536
&refid=7

I have no idea where these are coming from or how to get access to them.  Any 
ideas would be appreciated as this functionality (or lack thereof) pretty much 
breaks my client project I've been working on for two months.  Come on Adobe if 
you want us to use your tools you HAVE to give us better support that this.

WE'LL PAY FOR IT EVEN, JUST GIVE US SOME HELP!!!

Original issue reported on code.google.com by a...@driftlab.com on 4 Jun 2011 at 4:00

GoogleCodeExporter commented 9 years ago
Is your logout callback being called? Can you provide some code?

Original comment by rovertn...@gmail.com on 6 Jun 2011 at 3:54

GoogleCodeExporter commented 9 years ago
A Facebook bug has been opened for this issue
http://bugs.developers.facebook.net/show_bug.cgi?id=17217

Original comment by edwar...@gmail.com on 6 Jun 2011 at 4:01

GoogleCodeExporter commented 9 years ago
I was able to solve it by actually using this code:

        protected function logout (callback : Function = null, appOrigin : String = null, webView : StageWebView = null) : void
        {
            this.logoutCallback = callback;

            this.stageRef = stageRef;
            if (!webView)
            {
                this.webView = this.createWebView ();
            }
            else
            {
                this.webView = webView;
                this.webView.stage = this.stageRef;
            }

            this.webView.assignFocus ();
            this.webView.viewPort = new Rectangle (110, 110, this.stageRef.stageWidth - 220, this.stageRef.stageHeight - 220);

            logoutWindow = new MobileLogoutWindow (handleLogout);

            var logoutURL : String =    "https://www.facebook.com/logout.php" + 
                                        "?next=" + 
                                        "http://www.mywebsitename.com/" + 
                                        "&access_token=" + 
                                        FacebookMobile.getInstance().session.accessToken;

            trace ("logoutURL : " + logoutURL);

            logoutWindow.open (logoutURL, this.webView);

            //clears cookie for mobile.
            //          var params : Object       = {};
            //          params.confirm = 1;
            //          params.next = appOrigin;
            //          var req : FacebookRequest = new FacebookRequest ("http://m.facebook.com/logout.php");
            //
            //          openRequests[req] = handleLogout;
            //          req.call ("", params, handleRequestLoad);

            var so : SharedObject     = SharedObject.getLocal (SO_NAME);
            so.clear ();
            so.flush ();

            session = null;
        }

This is the ONLY thing that is working right now.  Although I have no idea how 
long this will work for, but I CAN tell you this... What is currently 
integrated into the lib isn't.

Original comment by a...@driftlab.com on 6 Jun 2011 at 4:02

GoogleCodeExporter commented 9 years ago
Please let us know if you implement a legit fix.  Thank you!

Original comment by a...@driftlab.com on 6 Jun 2011 at 4:03

GoogleCodeExporter commented 9 years ago
Re: the workaround above, here are you finding the class MobileLogoutWindow?  I 
don't see it in the latest source...

Original comment by flowers....@gmail.com on 8 Jun 2011 at 2:45

GoogleCodeExporter commented 9 years ago
Oh sorry I just duped the mobile login window basically, same deal.

Original comment by a...@driftlab.com on 8 Jun 2011 at 5:08

GoogleCodeExporter commented 9 years ago
Tried using the above example. Having a bit of trouble getting it to work. Is 
there any other part of the code that needs to be.modified. Could we possibly 
get the source or link to the mobile log out class. Thank you for your help. :)

Original comment by sirpedr...@gmail.com on 9 Jun 2011 at 2:59

GoogleCodeExporter commented 9 years ago
Here is the MobileLogoutWindow class:

Basically you will setup a listener (just as the login window has) to allow you 
to listen for a successful logout.

/*
Copyright (c) 2010, Adobe Systems Incorporated
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

* Neither the name of Adobe Systems Incorporated nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.facebook.graph.windows
{

    import com.facebook.graph.core.FacebookURLDefaults;
    import com.facebook.graph.utils.FacebookDataUtils;

    import flash.desktop.NativeApplication;
    import flash.display.Screen;
    import flash.display.Sprite;
    import flash.display.Stage;
    import flash.events.Event;
    import flash.events.TimerEvent;
    import flash.geom.Point;
    import flash.geom.Rectangle;
    import flash.media.StageWebView;
    import flash.net.URLRequest;
    import flash.net.URLRequestDefaults;
    import flash.net.URLRequestMethod;
    import flash.net.URLVariables;
    import flash.utils.Timer;

    /**
     * Displays a new NativeWindow that allows the current user to login to
     * Facebook. The login process found at:
     * http://developers.facebook.com/docs/authentication/desktop,
     * will be handled by this class.
     *
     */
    public class MobileLogoutWindow extends Sprite
    {

        protected var logoutRequest : URLRequest;
        protected var userClosedWindow : Boolean = true;
        private var webView : StageWebView;

        public var logoutCallback : Function;

        /**
         * Creates a new LoginWindow instance.
         * @param loginCallback Method to call when login is successful
         *
         */
        public function MobileLogoutWindow (logoutCallback : Function)
        {
            this.logoutCallback = logoutCallback;
            super ();
        }

        /**
         * Opens a new login window, pointing to the Facebook authorization
         * page (https://graph.facebook.com/oauth/authorize).
         *
         * @param applicationId Current ID of the application being used.
         * @param extendedPermissions (Optional) List of extended permissions
         * to ask the user for after login.
         * @param point (Optional) Starting point for the LoginWindow.
         * If null, the window will be centered on the current user's screen.
         *
         * @see http://developers.facebook.com/docs/authentication/desktop
         *
         */
        public function open (logoutURL : String, webView : StageWebView) : void
        {
            this.webView = webView;

            logoutRequest = new URLRequest ();
            logoutRequest.method = URLRequestMethod.GET;
            logoutRequest.url = logoutURL;

            showWindow (logoutRequest);
        }

        public function close () : void
        {
            webView.removeEventListener (Event.LOCATION_CHANGE, handleLocationChange);

            userClosedWindow = false;
            webView.dispose ();
            webView = null;
        }

        protected function showWindow (req : URLRequest) : void
        {
            webView.addEventListener (Event.LOCATION_CHANGE, handleLocationChange, false, 0, true);

            webView.loadURL (req.url);
        }

        protected function handleLocationChange (event : Event = null) : void
        {
            trace ("handleLocationChange : webView.location = " + webView.location);
            var location : String = webView.location;

            trace ("location = " + location);

            if (location == "http://www.yourwebsite.com/" || location == "https://www.yourwebsite.com/")
            {
                logoutCallback ("http://www.yourwebsite.com/", null);

                userClosedWindow = false;
                webView.dispose ();
                webView = null;
            }
        }
    }
}

Original comment by losthum...@gmail.com on 9 Jun 2011 at 2:44

GoogleCodeExporter commented 9 years ago
Would there be any chance we can a working example and the files. An FLA, AS, 
and the Facebook Classes?

This would be much appreciated. Thank you for your time.

Sincerely,
Peter Tucker

Original comment by sirpedr...@gmail.com on 17 Aug 2011 at 11:47

GoogleCodeExporter commented 9 years ago
Is this still an issue with the latest api?

Original comment by edwar...@gmail.com on 26 Oct 2011 at 8:12

GoogleCodeExporter commented 9 years ago
u can find solution for currect logout url

http://phpdog.blogspot.in/2012/03/solution-for-facebook-logouturl-not.html

Original comment by prabi...@gmail.com on 28 Mar 2012 at 1:12