龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > php编程 >

360网盘地址解析

时间:2014-07-22 14:49来源: 作者: 点击:
分享到:
360网盘地址解析-curl方法
360网盘地址解析-curl方法
$url='http://yunpan.cn/QXrZEiy92C9V5';
function get_downloadurl($url){
	$headers = get_headers($url,1);
	$zhenurl=$headers['Location'];  //Location  L大写
	$yuanma=file_get_contents($zhenurl);
	preg_match("/(?:nid\s\:\s\')([\s\S]*)(?:',[\s]*fhash)/i",$yuanma,$nid_arr);//*获取nid
	$surl_arr=explode('/',$zhenurl);
	//preg_match("/(?:\/lk\/)(.*)/i",$zhenurl,$surl_arr);  //print_r($surl_arr);
	$host=$surl_arr[2];
	$surl=$surl_arr[4];
	$nid=$nid_arr[1];
	$data='shorturl='.$surl.'&nid='.$nid;						//shorturl=QXrZEiy92C9V5&nid=13771433123969454
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, 'http://'.$host.'/share/downloadfile/');
	curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
	$json = curl_exec($ch);     //返回的是 json
	curl_close($ch);
	$back=json_decode($json, true);   
	$downloadurl=$back['data']['downloadurl'];
	return $downloadurl;
}
echo get_downloadurl($url);
精彩图集

赞助商链接