我有同樣的問題,我使用源文件結束(這已經非常的教育,太),你可以從谷歌代碼下載: 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