<?php //使用方法:weibo.php?url=微博视频地址 error_reporting(0); $domain = trim($_SERVER['SERVER_NAME']); $opendomain = array("127.0.0.1","localhost","lanyes.org"); if(in_array($domain, $opendomain)){ $url = isset($_GET['url']) ? addslashes($_GET['url']) : 'https://weibo.com/tv/show/1034:4594989955743747'; $url = str_replace('?from=old_pc_videoshow','',$url); preg_match('/show\/(.*)/i', $url, $matches); $fid = $matches[1]; if(!$fid){die('蓝叶提醒:获取错误,请检测微博视频网址是否正确。');} $content = 'https://video.h5.weibo.cn/s/video/object?object_id='.$fid; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$content); curl_setopt($ch, CURLOPT_HEADER,0); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,0); curl_setopt($ch, CURLOPT_REFERER,$url); curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36'); $output = curl_exec($ch);curl_close($ch);$data = json_decode($output,true); if($data['ok']){ $sd_url = str_replace('http','https',$data['data']['object']['stream']['url']); $hd_url = str_replace('http','https',$data['data']['object']['stream']['hd_url']); if($hd_url){ header('location:'.$hd_url);exit(); }else{ header('location:'.$sd_url);exit(); } }else{ die('获取错误,请检测微博视频网址是否正确。');//www.8gws.com } }else{ die('友情提示:请勿盗链。'); }