当前位置:首页 > php源码 > 正文

网易邮箱网盘文件调用外链代码

网易邮箱一直都有邮箱网盘功能,登陆时选择网易邮箱6.0版本,登陆后左侧点击文件中心,进入后上传文件都可以生成分享地址,拿到生成地址跟下载提取码,就可以利用下面的php代码在线播放预览,下面的代码虽然可以实现站外调用播放分享的网易邮箱网盘文件,但是网易限制了下载次数,只能下载播放20次,所以下面的代码只能测试学习用用

?php
//test: http://域名/163.php?id=
error_reporting(0);
$id = addslashes($_GET['id']);
$code = addslashes($_GET['code']);
$downapi = 'http://nf.mail.163.com/netfolder/web/anonyDownload.do';
$url = 'http://u.163.com/'.$id;
$refer = 'http://u.163.com/'.$id;
$headurl = get_headers($url, TRUE);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $headurl['Location']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
curl_setopt($ch, CURLOPT_REFERER, $refer);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.154 Safari/537.36 LBBROWSER');
$output = curl_exec($ch);
curl_close($ch);
preg_match('#var(.*?)fileId(.*?)=(.*?)(.*?);#',$output,$fileID);
preg_match('#var(.*?)fileName(.*?)=(.*?)"(.*?)";#',$output,$fileNAME);
preg_match('#var(.*?)ownerId(.*?)=(.*?)(.*?);#',$output,$ownerID);
$fileurl = $downapi.'?fileId='.str_replace(" ","",$fileID[4]).'&fileName='.urlencode($fileNAME[4]).'&ownerId='.str_replace(" ","",$ownerID[4]).'&shareKey='.$code.'&product=cloudstorage.mail.163&callback=parent.fDownloadCallback&retype=1';
header('location:'.$fileurl);exit();
?>

发表评论