下载文件
该接口用于下载文件,请求的userid需有下载权限。
请求方式:POST(HTTPS)
请求地址: https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_download?access_token=ACCESS_TOKEN
获取到文件下载地址后还需要带上cookie才能下载
$url = "https://sz-btfs-v2-down.wework.ftn.qq.com/ftn_handler/6f47b7b6b5a.docx";
$header = array('Cookie:FTN5K=684a3183');
$oCurl = curl_init();
curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($oCurl, CURLOPT_SSLVERSION, 1); //CURL_SSLVERSION_TLSv1
curl_setopt($oCurl, CURLOPT_HEADER, 0); //设置header
curl_setopt($oCurl, CURLOPT_URL, $url);
curl_setopt($oCurl, CURLOPT_TIMEOUT, 10);
curl_setopt($oCurl, CURLOPT_HTTPHEADER, $header);
curl_setopt($oCurl, CURLOPT_HEADERFUNCTION, function ($resURL, $strHeader) { //文件下载的形式
if (preg_match('/^Content-Disposition/i', $strHeader)) {
header($strHeader);
}
if (preg_match('/^Content-Type/i', $strHeader)) {
header($strHeader);
}
return strlen($strHeader);
});
$sContent = curl_exec($oCurl);
curl_close($oCurl);