编辑:我正在尝试在本地执行以下操作
我正在尝试为 Flash 应用程序做一个非常简单的 Facebook 实现。我正在使用“GraphAPI_Web_1_8_1.swc”。这是主要时间线的代码:
import FBLog;
import fanlib.utils.Debug;
addChild(Debug.field); // simply adds a textfield on stage for debugging
FBLog.INSTANCE;
和 FBLog 类代码:
package {
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.events.MouseEvent;
import fanlib.utils.Utils;
import fanlib.utils.Debug;
import com.facebook.graph.Facebook;
public class FBLog extends EventDispatcher
{
static public const CONNECTED:String = "CONNECTED";
static public const INSTANCE:FBLog = new FBLog();
private var _applicationID:String;
private var _extendedPermissions:Object;
public function get applicationID():String { return _applicationID; }
public function FBLog()
{
super();
if (INSTANCE) throw "What?";
new DelayedCall(init, 0.5);
}
private function init():void {
_applicationID = "408526019168127";
//Set permissions to ask for
_extendedPermissions = {scope:"read_stream, publish_stream, user_about_me, read_friendlists, user_photos"};
//Initialize facebook
try {
Debug.field.appendText("Issuing Facebook init...");
Facebook.init(_applicationID, handleInit);
Debug.field.appendText("Issued Facebook init...");
} catch (e:Error) { Debug.field.appendText("Facebook not initialized!" + "\n" + e); }
}
private function handleInit(response:Object, fail:Object):void {
Debug.field.appendText("end init!");
if (!response) response = {};
if (!fail) fail = {};
trace(Utils.PrettyString(response), Utils.PrettyString(fail));
dispatchEvent(new Event(CONNECTED));
}
public function login(e:MouseEvent = null):void {
Debug.field.appendText("start login");
Facebook.login(handleLogin, _extendedPermissions);
}
private function handleLogin(response:Object, fail:Object):void {
Debug.field.appendText("end login");
if (!response) response = {};
if (!fail) fail = {};
Debug.field.appendText(Utils.PrettyString(response) + "\n" + Utils.PrettyString(fail));
dispatchEvent(new Event(CONNECTED));
}
}
}
出于某种我无法理解的原因,从未调用过“handleInit”函数。这是我在文本字段中得到的输出:
发出 Facebook 初始化...发出 Facebook 初始化...
我从来没有得到额外的“结束初始化!”。
现在,我尝试将此 SWF 嵌入到一个看起来像这样的 HTML 中,但没有用:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Digital TradeShow</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css" media="screen">
#myContent { width:1300 height:700; }
body { margin:0; padding:0; overflow:auto; text-align:center; background:white;}
#myAlternativeContent { /* style alt content */ }
</style>
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
var flashvars = {};
var params = { allowfullscreen:"true", wmode:"window" };
var attributes = {};
swfobject.embedSWF("FBLog.swf", "myContent", "1300", "700", "10.2", "expressInstall.swf", flashvars, params, attributes);
</script>
<script type="text/javascript">
function PopupCenter(pageURL,title,w,h,scroll) {
var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);
var targetWin = window.open(pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars='+scroll+', resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
}
</script>
<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
</head>
<body>
<div id="fb-root"></div>
<div id="myContent">
<div id="myAlternativeContent">
<h1>Alternative content</h1>
<p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>
</div>
</div>
</body>
</html>
相同的输出。我可能做错了什么?我使用的 APP_ID 是正确的。