0

我尝试在我的 Flash 应用程序中创建登录 Facebook 机制。但是当我尝试获取令牌访问表单回调页面时,将获取并发送到 flash 的 ExternalInterface.addCallback 运行良好。我该如何解决?

这是我的代码:

var accessToken:String ="";
tombol.addEventListener(MouseEvent.CLICK, onClick);

function onClick(e:MouseEvent):void{
    attemptToAuthenticate();
    tombol.removeEventListener(MouseEvent.CLICK, onClick);
}

function attemptToAuthenticate(...permissions):void{
  var scope:String = "";
  if (permissions.length > 0){
   scope = "&scope=" + permissions.join(",");
  }
  ExternalInterface.call("window.open","https://graph.facebook.com/oauth/authorize?client_id=245127485627150&type=user_agent&redirect_uri=http://localhost/satu/callback.html"+scope,"facebookLoginWindow","height=370, width=600");    

teks.text = "success get token from server fb";

ExternalInterface.addCallback("setAccessToken", setAccessToken);    

ExternalInterface.call("function() {"
       + "window.setAccessToken = function(hashValue){"
       + "var satu1 = document.getElementById('satu');"
       + "satu1.setAccessToken(hashValue);"
       + "}"
       + "}");

ExternalInterface.call("window.alert", "hashValue");
teks.text += " get from flash"; 
 }

 function setAccessToken(a_hashValue:String):void{
  teks.text += "setaccesstoken";
  var hashParams:Array = a_hashValue.substr(1).split("&");
      var hashKeyAndValue:Array;
      for (var i:int = 0; i < hashParams.length; i++){
      hashKeyAndValue = (hashParams[i] as String).split("=");
  if (hashKeyAndValue[0] == "access_token"){
      this.accessToken = hashKeyAndValue[1];
      break;
    }
  }
  this.request("me","");
  }

 // some code below.....
4

0 回答 0