我从Dropbox下载文件并将其提供给用户,但出了点问题:
这是MODX的代码段,因此返回函数:
<?php
$token='xxxxx';
$url = 'https://content.dropboxapi.com/2/files/download';
$header_array = array(
'Authorization: Bearer ' . $token,
'Content-Type:',
'Dropbox-API-Arg: {"path":"' . "/usersUpload/W4zUKvsYbW8dlWi2XtZkdo5kPzoThXq3rBKkTtkNd7o4BPVDrt.png" . '"}'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header_array);
$output_array = array();
$output = curl_exec($ch);
if ($output === FALSE)
{
echo "curl error: " . curl_error($ch);
}else{
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=file.png');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
$return = $response->body;
}
return;
答案 0 :(得分:0)
将代码移植到单独的php文件中有助于解决此问题。 MODX使用返回的值执行某些操作。