Dropbox PHP API 问题
我不断遇到 dropbox php api 的问题,我只是想让它使用获取元。但我不断收到以下错误?
我认为问题就在这里。
public function getToken($email, $password) {
throw new Dropbox_Exception('This API method is deprecated as of the version 1 API');
}
这是我的代码。
$consumerKey = 'oksergerg1x1r';
$consumerSecret = 'zexb0rg6h54tgzzb';
require($_SERVER['DOCUMENT_ROOT'] . '/wp/includes/Dropbox/autoload.php');
//session_start();
$oauth = new Dropbox_OAuth_Wordpress($consumerKey, $consumerSecret);
echo "<pre>";
print_r($oauth);
echo "</pre>";
// If the PHP OAuth extension is not available, you can try
// PEAR's HTTP_OAUTH instead.
// $oauth = new Dropbox_OAuth_PEAR($consumerKey, $consumerSecret);
$dropbox = new Dropbox_API($oauth);
$tokens = $dropbox->getToken('[email protected]', 'secretpassword');
// You are recommended to save these tokens, note that you don't
// need to save the username and password, so just ask your user the
// first time and then destroy them.
echo "Tokens:\n";
print_r($tokens);
所以我说 getToken 函数已经贬值了,那么我们应该用什么来代替呢?
更新
好吧,抱歉,谷歌搜索了 abit,我发现新版本不再支持 getTokens,即使它们出于某种原因仍然在示例中。
所以我现在很困惑。
我正在尝试设置一个应用程序,以便人们可以输入他们的保管箱电子邮件和密码。然后它将从他们的帐户中提取他们的所有元数据。
使用新代码如何授予用户访问权限?如果他们没有电子邮件和密码,我如何获得他们正确的令牌???
抱歉,我对此感到非常困惑,过去两天我一直在努力解决这个问题。
I keep getting issues with dropbox php api, i am just trying to get it to work using getmeta. but i keep getting the following error??
I think the issues is here.
public function getToken($email, $password) {
throw new Dropbox_Exception('This API method is deprecated as of the version 1 API');
}
here is my code.
$consumerKey = 'oksergerg1x1r';
$consumerSecret = 'zexb0rg6h54tgzzb';
require($_SERVER['DOCUMENT_ROOT'] . '/wp/includes/Dropbox/autoload.php');
//session_start();
$oauth = new Dropbox_OAuth_Wordpress($consumerKey, $consumerSecret);
echo "<pre>";
print_r($oauth);
echo "</pre>";
// If the PHP OAuth extension is not available, you can try
// PEAR's HTTP_OAUTH instead.
// $oauth = new Dropbox_OAuth_PEAR($consumerKey, $consumerSecret);
$dropbox = new Dropbox_API($oauth);
$tokens = $dropbox->getToken('[email protected]', 'secretpassword');
// You are recommended to save these tokens, note that you don't
// need to save the username and password, so just ask your user the
// first time and then destroy them.
echo "Tokens:\n";
print_r($tokens);
so i says that the getToken function has depreciated so what are we supposed to use instead??
UPDATE
Ok sorry googled abit and i see that the new version does not support getTokens anymore even though they are in the examples still for some reason.
So i am confused now.
I am trying to setup an app so people can enter their dropbox email and password. Then it will pull all their metadata in from their account.
With the new code how do i give a user access? if their is no email and password how do i get their correct tokens???
Sorry i am really confused with this now been working for the past two days trying to suss this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看一下单元测试。它们应该被视为如何使用该库的最新示例。 Dropbox 在最新版本的 API 中弃用了一些身份验证内容,这就是我们必须在库中弃用它的原因。它在我的列表中更新文档和示例,我真的很忙。
基本上,您需要执行以下操作:
在 Oauth 提供程序类上,调用:
$tokens = $oauth->getRequestToken();
然后将用户重定向到
$oauth->getAuthorizeUrl ()
,以便他们可以通过 Dropbox 进行身份验证并批准您的访问。最后,调用:
您可以将
$tokens
存储在某处以供将来连接时使用。您可以通过致电使用它:希望有帮助。您还可以做更多事情(例如为 Dropbox 提供回调 URL 以将用户重定向回)。只需检查源测试目录中的 APITests.php 文件和设置文件: https://github.com/Dropbox-PHP/dropbox-php/tree/master/tests
Take a look at the Unit tests. They should be considered more up-to-date examples for how to use the library. Dropbox deprecated some of the authentication stuff in the latest version of the API, that's why we had to deprecate it in the library. It's on my list to update the documentation and examples, I've just been really busy.
Basically, you need to do the following:
On your Oauth provider class, call:
$tokens = $oauth->getRequestToken();
Then redirect the user to
$oauth->getAuthorizeUrl()
so they can authenticate with Dropbox and approve your access.Finally, call:
You can store
$tokens
somewhere for future use in connecting. Which you will use by calling:Hope that helps. There is more you can do (such as providing a callback URL for Dropbox to redirect the user back to). Just check the APITests.php file and the setup file in the tests directory of the source: https://github.com/Dropbox-PHP/dropbox-php/tree/master/tests