0

我正在使用 adobe air 和 flash pro 制作移动应用程序(Android 和 IOS)。这是我第一次尝试使用 facebook api。我遇到的问题(我认为)是 facebookMobile.login 方法在按下登录 btn 后没有返回任何内容,即我没有收到登录或登录失败的跟踪消息。如果我至少收到登录失败消息,至少我会知道正在调用 onLogin 函数。下面是我的 as3 类

package  {

import flash.display.MovieClip;
import flash.media.*;
import flash.media.Camera;
import flash.media.CameraUI;
import flash.events.Event;
import flash.events.*;  
import flash.ui.Multitouch;
import flash.ui.MultitouchInputMode;
import flash.display.Sprite;

import com.facebook.graph.FacebookMobile;
//import com.facebook.graph.windows;


public class Main extends MovieClip {

    private var logInBtn:LogIn = new LogIn();
    private var vidCon:Video = new Video();
    static const APP_ID:String = "1234512345";
    protected var extendedPermissions:Array = ["publish_stream","user_website","user_status","user_about_me"];

    public function Main() {
        // constructor code
        trace("main loaded");
        Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
        FacebookMobile.init(APP_ID, onInit);
    }

    public function onInit(success:Object, fail:Object):void{
        if (success){ 
            trace("Already logged in");
        }
        else{
            trace("Not logged in");
            addChild(logInBtn);
            logInBtn.x = logInBtn.y =200;
            logInBtn.addEventListener(TouchEvent.TOUCH_BEGIN, logInbtnPressed);
        }
    }

    private function logInbtnPressed(e:TouchEvent){

        removeChild(logInBtn);
        FacebookMobile.login(onLogin,stage, extendedPermissions);
    }
    //--the below function dosnt seem to be getting called--
    public function onLogin(success:Object, fail:Object):void{
        if (success){
            trace("Logged In\n");
            loggedIn();
        }
        else{
            trace("Login Failed\n");
        }
    }

    public function onLogout(success:Boolean):void {
        trace("Log out");
    }
}

任何见解将不胜感激。

4

1 回答 1

0

我找到了向 facebookMobile.login 调用添加 Web 视图所需的解决方案。

private var  webView = new StageWebView();
webView.stage = stage;
webView.viewPort = new Rectangle(10, 10, (stage.stageWidth -20), (stage.stageHeight - 20));
FacebookMobile.login( onLogin , this.stage, extendedPermissions, webView);
于 2013-11-06T18:19:00.830 回答