简体   繁体   English

Adobe Air和Dropbox

[英]Adobe Air and Dropbox

I'm trying to integrate dropbox into my BB Playbook app using adobe air in flashbuilder 4.6. 我正在尝试使用Flashbuilder 4.6中的Adobe Air将Dropbox集成到我的BB Playbook应用程序中。 I got the API from http://code.google.com/p/dropbox-as3/wiki/EXAMPLES and I'm also using that example. 我从http://code.google.com/p/dropbox-as3/wiki/EXAMPLES获得了API,并且我也在使用该示例。

public function getRequestToken():void
{
    dropAPI.requestToken();
    var handler:Function = function (evt:DropboxEvent):void
    {
            dropAPI.removeEventListener(DropboxEvent.REQUEST_TOKEN_RESULT, handler);
            var obj:Object = evt.resultObject;
            reqTokenKeyLabel.text = obj.key;
            reqTokenSecretLabel.text = obj.secret;
            // goto authorization web page to authorize, after that, call get access token 
            if (oauthRadioBtn.selected) {
                    Alert.show(dropAPI.authorizationUrl);
            }
    };
    dropAPI.addEventListener(DropboxEvent.REQUEST_TOKEN_RESULT, handler);
    if (!dropAPI.hasEventListener(DropboxEvent.REQUEST_TOKEN_FAULT)) {
            dropAPI.addEventListener(DropboxEvent.REQUEST_TOKEN_FAULT, faultHandler);
    }
}

This executes as expected but I don't know how to go further, I tried sending the user to the link generated and I allow the application but the get access token still fails. 这将按预期执行,但我不知道如何进行进一步操作,我尝试将用户发送到生成的链接,并且允许应用程序使用,但get访问令牌仍然失败。 I feel like there is missing code, how does my application know what the access token is? 我感觉好像缺少代码,我的应用程序如何知道访问令牌是什么? should I not be getting something back from dropbox when the user allows the application? 用户允许应用程序时,我是否应该不从Dropbox取回东西?

Once the user has accepted the app in the web browser you should call this function in order to get the access token and secret: 一旦用户在网络浏览器中接受了该应用程序,则应调用此函数以获取访问令牌和密码:

public function getAccessToken():void{

    dropAPI.accessToken();
    var handler:Function = function (evt:DropboxEvent):void{
        dropAPI.removeEventListener(DropboxEvent.ACCESS_TOKEN_RESULT, handler);
        var obj:Object = evt.resultObject;
        myAccessToken = obj.key;
        myAccessSecret = obj.secret;
    };
    dropAPI.addEventListener(DropboxEvent.ACCESS_TOKEN_RESULT, handler);
    if (!dropAPI.hasEventListener(DropboxEvent.ACCESS_TOKEN_FAULT)) {
        dropAPI.addEventListener(DropboxEvent.ACCESS_TOKEN_FAULT, faultHandler);
    }
}

Once you have them you can save them for future use. 拥有它们后,您可以保存它们以备将来使用。 After that you have establish connection with Dropbox. 之后,您与Dropbox建立连接。

I hope this will help you 我希望这能帮到您

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM