我有同样的问题,我使用源文件结束(这已经非常的教育,太),你可以从谷歌代码下载: http://code.google.com/p/facebook-actionscript-api/downloads/detail?name=GraphAPI%20Source_1_5.zip&can=2&q=
的例子大多用于制作Flex或AIR,但一旦你掌握了基础知识,它就非常简单。这里有一个例子:
//--- This line should be at the constructor of your main class, so you can tell from the beginning if the user is already logged in facebook and should not be prompted to login again
Facebook.init('your-app-id', handleLogin);
//--- This function is called both as the callback of the init method and the login method
protected function handleLogin($success:Object, $fail:Object):void {
if ($success) {
//---- your code to the logged in user
}
else{
Facebook.getLoginStatus ()
Facebook.addJSEventListener('auth.sessionChange', detectLogin)
}
}
private function detectLogin($e:Object):void{
if ($e.status == "connected"){
//---- your code to the logged in user
}
else{
//---- the user cancelled the request
}
}
//-------This function must be called from the login button handler or something like that
public function connect():void {
//--- here you have to ask for the permissions you need (the permissions are kind of self explanatory, for a full list visit [here][2]. I'm putting these two just for example purposes)
var permissions:Array = ['publish_stream','user_photos'];
//--- this method will call a html popup directly from facebook so the user can write his username and password securely. The first parameter is the callback function and the second is a string of the permissions you ask for.
Facebook.login(handleLogin, {perms:permissions.join(',')});
}
正如你所看到的,你这是一种与“getLoginStatus()”两个人通话,但我就是不能让没有它的工作。我认为这可能不是最好的解决方法,所以如果任何人有更好的解决方案,我会很感激:)
..你如何导入“Facebook”?我试图让它工作,但我有错误“1120:访问未定义的属性Facebook”。 – 2011-06-14 02:55:52