Dropbox Api上传错误

时间:2013-12-16 04:45:22

标签: dropbox-api

我正在为我的客户开发一个应用程序,允许将他们的文件上传到Dropbox .. 我搜索网络并得到一些代码,下面是我得到的代码

<?php
if ($_POST) {
    require 'DropboxUploader.php';

    try {
        if ($_FILES['file']['error'] !== UPLOAD_ERR_OK)
            throw new Exception('File was not successfully uploaded from your computer.');

        if ($_FILES['file']['name'] === "")
            throw new Exception('File name not supplied by the browser.');

        // Upload
        $uploader = new DropboxUploader($_POST['email'], $_POST['password']);
        $uploader->upload($_FILES['file']['tmp_name'], $_POST['destination'], $_FILES['file']['name']);

        echo '<span style="color: green">File successfully uploaded to your Dropbox!</span>';
    } catch (Exception $e) {
        // Handle Upload Exceptions
        $label = ($e->getCode() & $uploader::FLAG_DROPBOX_GENERIC) ? 'DropboxUploader' : 'Exception';
        $error = sprintf("[%s] #%d %s", $label, $e->getCode(), $e->getMessage());

        echo '<span style="color: red">Error: ' . htmlspecialchars($error) . '</span>';
    }
}
?>
<form method="POST" enctype="multipart/form-data">
<dl>
<dt><label for="email">Dropbox e-mail</label></dt>
<dd><input type="text" id="email" name="email"></dd>
<dt><label for="password">Dropbox password</label></dt>
<dd><input type="password" id="password" name="password"></dd>
<dt><label for="destination">Destination directory (optional)</label></dt>
<dd><input type="text" id="destination" name="destination"> e.g. "dir/subdirectory", will be created if it
doesn't exist
</dd>
<dt><label for="file"></label>File</dt>
<dd><input type="file" id="file" name="file"></dd>
<dd><input type="submit" value="Upload the file to my Dropbox!"></dd>
</dl>
</form>

当我尝试使用此脚本上传文件时,我得到了

错误:[DropboxUploader]#268697857卷曲错误:(#60)SSL证书问题,验证CA证书是否正常。详细信息:错误:14090086:SSL例程:SSL3_GET_SERVER_CERTIFICATE:证书验证失败

任何人都可以帮我解决这个问题..是否有任何api上传skydrive和谷歌驱动器

1 个答案:

答案 0 :(得分:3)

打开你的DropboxUploader.php并:

  1. 对此发表评论:

    switch ($this->caCertSourceType) {
            case self::CACERT_SOURCE_FILE:
                curl_setopt($ch, CURLOPT_CAINFO, (string) $this->caCertSource);
                break;
            case self::CACERT_SOURCE_DIR:
                curl_setopt($ch, CURLOPT_CAPATH, (string) $this->caCertSource);
                break;
        }
    
  2. 之前添加:

    curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__)."/cacert.pem");
    
  3. 从您文件夹中的http://curl.haxx.se/ca/cacert.pem下载并复制cacert.pm。

  4. 已经完成了!