在 Dropbox 版本 2 中下载文件时出现问题 Php Api

Issue in Downloading File In Dropbox Version 2 Php Api

大家好, 我正在使用此代码从 Dropbox Version 2 下载文件 Php Api.But 我在文件中还没有成功 downloading.Lets 看看我正在使用的脚本

function dbx_get_file($token, $in_filepath, $out_filepath)
{
$out_fp = fopen($out_filepath, 'w+');
if ($out_fp === FALSE)
    {
    echo "fopen error; can't open $out_filepath\n";
    return (NULL);
    }

$url = 'https://content.dropboxapi.com/2/files/download';

$header_array = array(
    'Authorization: Bearer ' . $token,
    'Content-Type:',
    'Dropbox-API-Arg: {"path":"' . $in_filepath . '"}'
);

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header_array);
curl_setopt($ch, CURLOPT_FILE, $out_fp);

$metadata = null;
curl_setopt($ch, CURLOPT_HEADERFUNCTION, function ($ch, $header) use (&$metadata)
    {
    $prefix = 'dropbox-api-result:';
    if (strtolower(substr($header, 0, strlen($prefix))) === $prefix)
        {
        $metadata = json_decode(substr($header, strlen($prefix)), true);
        }
    return strlen($header);
    }
);

$output = curl_exec($ch);

if ($output === FALSE)
    {
    echo "curl error: " . curl_error($ch);
    }

curl_close($ch);
fclose($out_fp);

return($metadata);
} // dbx_get_file()

在此处调用此函数。

dbx_get_file("<Access-token>", '/Screenshot_1.png', 'Screenshot_1.png');

我还用我的 Dropbox O-auth 2 访问令牌替换了这个 "Access-token"。 请告诉我我做错了什么的答案?或者有没有其他方法可以使用 DropBox 版本 2 PHP Api 从 Dropbox 下载文件。 谢谢

我已经使用 Requests Library 完成了 https://github.com/rmccue/Requests/ 这是我的代码

include('Requests-master/library/Requests.php');
Requests::register_autoloader();
$token="Your Access Token is here";
$response = 
Requests::post("https://content.dropboxapi.com/2/files/download", array(
'Authorization' => "Bearer ".$token,
'Dropbox-Api-Arg' => json_encode(array('path' => '/Screenshot_1.png')),
));
$fileContent = $response->body;
/*Download the file using file_put_contents method*/
file_put_contents("Screenshot_1.png",$fileContent);
$metadata = json_decode($response->headers['Dropbox-Api-Result'], true);
echo "File " . $metadata["name"] . " has the rev " . $metadata["rev"] . ".\n";

文件下载成功...:)