如何使用Dropbox Chooser而不强制用户登录使用的Dropbox帐户 [英] How to use Dropbox Chooser without forcing the user to login to the Dropbox account used

查看:77
本文介绍了如何使用Dropbox Chooser而不强制用户登录使用的Dropbox帐户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将Dropbox选择器放在一起。想法是站点用户可以访问Dropbox按钮,并能够下载他们想要的任何文件。
当我登录到相关帐户,但我不能要求曾经使用过该帐户时,此方法工作正常。我不知道需要更改什么,将使用的域添加到Dropbox应用程序设置中,这是我的测试代码:

I am putting a Dropbox Chooser together. The idea is that site users will have access to the Dropbox button and will be able to download any file they want. This is working fine when I login to the account in question but I can't ask used to login to this account. I can't figure out what needs to be changed, the domain used is added to the Dropbox app settings, here is my test code:

<!DOCTYPE html>
<html>
    <head>
    <title>TODO supply a title</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://www.dropbox.com/static/api/2/dropins.js" id="dropboxjs" data-app-key="xxxxxxxxxxxx"></script>
    <script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
    </head>
   <body>
    <div id="container"></div>

    <script>

        var options = {

    linkType: "direct",
    multiselect: true,

    success: function(files) {
       for(i = 0; i< files.length; i++){

                  var link = document.createElement('a');
                  var br = document.createElement('br');
                  link.href = files[i].link;
                  link.textContent = files[i].link;
                  document.getElementById('container').appendChild(br);
                  document.getElementById('container').appendChild(link);                 
                } 
    }
};

        var button = Dropbox.createChooseButton(options);
        Dropbox.choose(options);
        document.getElementById('container').appendChild(button);

        file = {
    // Name of the file.
    name: "filename.txt",

    // URL to access the file, which varies depending on the linkType specified when the
    // Chooser was triggered.
    link: "https://...",

    // Size of the file in bytes.
    bytes: 464,

    // URL to a 64x64px icon for the file based on the file's extension.
    icon: "https://...",

    // A thumbnail URL generated when the user selects images and videos.
    // If the user didn't select an image or video, no thumbnail will be included.
    thumbnailLink: "https://...?bounding_box=75&mode=fit",
};

    </script>
  </body>
</html>


推荐答案

尝试此此链接

它可能会对您有所帮助。
首先,您必须注册您的应用程序,
,然后Dropbox将为您提供一些密钥:
将其保存在应用程序的authorize.php文件中,例如

it may help you . first you have to register your app , then Dropbox will provide you some keys: keep that in authorize.php file of your app e.g

<?php
$access_token = array (
  "oauth_token_secret" => "abcdefghilmnopqr",
  "oauth_token" => "stuvwxyzabcdefgh",
  "uid" => "1234567"
);

第一次运行应用程序时,index.php文件中的以下条件为真:

The first time your application is run, the following condition in the index.php file will be true:

<?php
if (!isset($access_token)) {
    header("Location: authorize.php");
    exit;
}

authorize.php将自动为您管理。

the authorize.php will manage automatically for you .

这篇关于如何使用Dropbox Chooser而不强制用户登录使用的Dropbox帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆