AnthonyLins / facebook-actionscript-api

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

Credits callback not being called in firefox #430

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
0. Use Firefox (Ver 14.1) (other versions not tested but worked with older 
versions tested and works with other browsers)
1. Create application using GraphAPI_Web_1_8_1.swc
2. Initialize, get session login etc (all good/working)
3. Create credits server/service (All working as evidenced by server logging 
complete and successful transaction)
4. Attempt to use any/all combinations of "Facebook.ui('pay', [ ITEM DETAILS 
OBJ ], [ CALLBACK FUNC]);"/"Facebook.ui('pay.prompt', [ ITEM DETAILS OBJ ], [ 
CALLBACK FUNC]);" and "method: 'pay.prompt'"/"method: 'pay'".

What is the expected output? What do you see instead?
What is expected is that upon completion credits server/service transaction the 
javascript library calls the callback function, this does not happen.
The purchase dialog completes successfully, the credits server/service 
completes successfully (trasnaction, created, updated, saved, responds and 
works with other browsers), but the callback function in the client app just 
isn't called.
Also, cancel in the purchase dialog doesn't work.

What version of the product are you using? On what operating system?
Tested on Win Vista and 7, using GraphAPI_Web_1_8_1.swc, Firefox 14.1

Please provide any additional information below.

Complete code for a test app:

package  
{
    import com.adobe.serialization.json.JSON;
    import com.facebook.graph.Facebook;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.system.Security;
    import flash.text.TextField;

    public class TestApp extends Sprite
    {
        public static var _WIDTH:int = 740;
        public static var _HEIGHT:int = 500;

        protected static const APP_ID:String = [ APP ID ];

        private var txt_output:TextField;
        private var btn_login:TextField;
        private var btn_purchase:TextField;

        public function TestApp() 
        {
            Security.loadPolicyFile("http://fbcdn-profile-a.akamaihd.net/crossdomain.xml");
            Security.loadPolicyFile("http://profile.ak.fbcdn.net/crossdomain.xml");
            Security.loadPolicyFile("http://fpdownload.adobe.com/pub/swz/crossdomain.xml");

            if (stage) init();
            else addEventListener(Event.ADDED_TO_STAGE, init);
        }

        private function init(e:Event = null):void 
        {
            removeEventListener(Event.ADDED_TO_STAGE, init);

            txt_output = new TextField();
            txt_output.width = 400; txt_output.height = _HEIGHT;
            addChild(txt_output);

            btn_login = new TextField();
            btn_login.x = 425; btn_login.y = 25;
            btn_login.width = 100; btn_login.height = 20;
            btn_login.text = "Login";
            btn_login.selectable = false;
            btn_login.border = true;
            btn_login.addEventListener(MouseEvent.CLICK, OnLoginClick);
            addChild(btn_login);

            btn_purchase = new TextField();
            btn_purchase.x = 425; btn_purchase.y = 50;
            btn_purchase.width = 100; btn_purchase.height = 20;
            btn_purchase.text = "Purchase";
            btn_purchase.selectable = false;
            btn_purchase.border = true;
            btn_purchase.addEventListener(MouseEvent.CLICK, OnPurchaseClick);
            btn_purchase.visible = false;
            addChild(btn_purchase);

            log("App started");

        }

        private function OnLoginClick(_event:Event):void
        {
            log("Initializing facebook stuffs...");
            Facebook.init(APP_ID, onFBInit, { scope:"publish_stream, user_about_me, read_friendlists, user_photos" } );
        }

        protected function onFBInit(result:Object, fail:Object):void
        {
            log("Facebook stuffs initialization complete.");

            if (result)
            { //already logged in because of existing session
                log("Confirmed Facebook session. Getting facebook user data...");
                Facebook.api('me', onFBUserLoad);
            } else
            {
                Util._trace("No existing Facebook session. Logging into Facebook...");
                Facebook.login(OnFBLogin);
            }
        }

        private function OnFBLogin(result:Object, fail:Object):void
        {
            if (result)
            { //successfully logged in
                Util._trace("Confirmed Facebook session. Getting facebook user data...");
                Facebook.api('me', onFBUserLoad);
            }
            else
                log("Failed to get facebook session! "+fail);
        }

        private function onFBUserLoad(result:Object, fail:Object):void
        {
            if (result)
            {
                log("Loaded user Facebook data.");

                btn_login.visible = false;
                btn_purchase.visible = true;
            }else
                log("Failed to get user info from facebook! " + fail);
        }

        private function OnPurchaseClick(_event:Event):void
        {
            log("Attempting to purchase item...");

            var order_info:Object;
            order_info =
            {
                item_id: "cash_funds_5_100"
            };

            var obj:Object;
            obj =
            {
                //method: 'pay',
                method: "pay.prompt",
                order_info: order_info,
                purchase_type: 'item',
                credits_purchase: false
            };

            //Facebook.ui('pay', obj, OnPurchaseResponse);
            Facebook.ui('pay.prompt', obj, OnPurchaseResponse);
            log("Purchase sent...");
        }

        public function OnPurchaseResponse(result:Object):void
        {
            log("Purchase Response " + new JSONObject(JSON.encode(result)));
        }

        private function log(_text:String):void
        {
            txt_output.text += _text + "\n";
        }
    }
}

Original issue reported on code.google.com by DexterFr...@gmail.com on 25 Jul 2012 at 10:40

GoogleCodeExporter commented 9 years ago
Whoops, ignore those 'Util._trace', they should be 'log's (Extracted from a 
larger application). I'll fix the post if I can figure out how/where.

Original comment by DexterFr...@gmail.com on 25 Jul 2012 at 10:43

GoogleCodeExporter commented 9 years ago
D'oh, and that should be Firefox 14.0.1

Original comment by DexterFr...@gmail.com on 25 Jul 2012 at 10:57

GoogleCodeExporter commented 9 years ago
Uuurgh,
After days of searching for similar problems, testing, stripping out elements 
of the project etc I finally found my problem* and it wasn't related to the 
facebook-actionscript-api. So if anyone found their way here with a similar 
problem, I'm afraid chances are that I don't have an answer for you.

(If someone knows how I can cancel/close/delete this issue please let me know).

(* If anyone is interested it was a stupid email hidding javascript snippet in 
a completely seperate Div that for some reason broke only the facebook dialog 
callbacks only in firefox.)

Original comment by DexterFr...@gmail.com on 27 Jul 2012 at 4:18

GoogleCodeExporter commented 9 years ago
i used these functions

private var txt_output:TextField;
        private var btn_login:TextField;
        private var btn_purchase:TextField;

        public function TestApp() 
        {
            Security.loadPolicyFile("http://fbcdn-profile-a.akamaihd.net/crossdomain.xml");
            Security.loadPolicyFile("http://profile.ak.fbcdn.net/crossdomain.xml");
            Security.loadPolicyFile("http://www.shopping.lk/sitemap.xml");

            if (stage) init();
            else addEventListener(Event.ADDED_TO_STAGE, init);
        }

Original comment by sanjana...@gmail.com on 21 Sep 2013 at 6:32