开发者

as3 flash facebook: any sample avaible?

开发者 https://www.devze.com 2023-02-03 00:39 出处:网络
The goal of my project if to authetificate users who use my flash application through Flash. I sucees it with Flex folowing this tutorial

The goal of my project if to authetificate users who use my flash application through Flash. I sucees it with Flex folowing this tutorial http://www.adobe.com/devnet/facebook/articles/video_facebook_quick_start.html

But I could not do it with flash ! When I download http://code.google.com/p/facebook-actionscript-api/downloads/list which swc shoudl I use: mobile/desktop/web开发者_如何学编程 ?

Then I tried with GraphAPI Examples_1_5.zip and got API Error Code: 191 API Error Description: The specified URL is not owned by the application Error Message: redirect_uri is not owned by the application.

ANy sample to authetificate an user in FLASH (not flex) avaible ?

Regards


I had the same issue and I ended using the source files (which have been very educational, too) that you can download from Google Code: http://code.google.com/p/facebook-actionscript-api/downloads/detail?name=GraphAPI%20Source_1_5.zip&can=2&q=

The examples are mostly made for Flex or AIR, but once you get the basics it's pretty simple. Here's an example:

//--- 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(',')});

        }

As you can see, you are making kind of a double call with "getLoginStatus()" but I just can't make it work without it. I think this may not be the best way to solve it, so if anyone has a better solution I would appreciate it a lot :)

0

精彩评论

暂无评论...
验证码 换一张
取 消