【问题标题】:as3 flash facebook: any sample avaible?as3 flash facebook:有可用的示例吗?
【发布时间】:2011-01-08 21:26:31
【问题描述】:

我项目的目标是验证通过 Flash 使用我的 Flash 应用程序的用户。 我按照本教程使用 Flex 成功了 http://www.adobe.com/devnet/facebook/articles/video_facebook_quick_start.html

但我不能用 flash 做到这一点! 当我下载http://code.google.com/p/facebook-actionscript-api/downloads/list 我应该使用哪个 swc:移动/桌面/网络?

然后我尝试使用 GraphAPI Examples_1_5.zip 并得到 API 错误代码:191 API 错误描述:指定的 URL 不属于应用程序 错误消息:redirect_uri 不属于应用程序。

任何在 FLASH(非 flex)中验证用户的示例可用吗?

问候

【问题讨论】:

    标签: flash actionscript-3 facebook


    【解决方案1】:

    我遇到了同样的问题,我最终使用了可以从 Google 代码下载的源文件(也很有教育意义): 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。”..
    猜你喜欢
    • 2012-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-02
    • 2013-12-07
    • 1970-01-01
    • 2016-12-21
    相关资源
    最近更新 更多