随着抖音短视频的火爆,催生了不少其他市场。有的人靠开发视频制作软件赚了盆满钵满,有人靠转发别人做好的视频也赚了不少,更有人简单做个抖音去水印的网站或小程序靠投放广告和接口收费大赚了一笔。
下面代码是抖音短视频去水印接口的源码,还不清楚流程的朋友可以研究研究。
- <?
- if ($_REQUEST['url']) {
- $agent_ua = "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X ) AppleWebkit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1";
- $api_url = "https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/";
- $longUrl = restoreUrl(trim($_REQUEST['url']));
- $idtk = get_curl($longUrl,0,0,0,0,$agent_ua);
- $itemID = getSubstr($idtk,'itemID:"','",');
- $dytk = getSubstr($idtk,'dytk:"','"});');
- $videoInfo = json_decode(get_curl($api_url.'?item_ids='.$itemID.$agent_ua,0),true);
- $code = $videoInfo['status_code'];
- if($code == 0) {
- $video = $videoInfo['item_list'][0]['video']['play_addr']['url_list'][0];
- $video = restoreUrl($video);
- $cover_pic = $videoInfo['item_list'][0]['video']['cover']['url_list'][0];
- $desc = $videoInfo['item_list'][0]['desc'];
- $data = ['code'=>"success",'msg'=>"解析成功",'content'=>['title'=>$desc,'cover'=>$cover_pic,'url'=>$video]];
- }else{
- $data = ['code'=>"error",'msg'=>"接口异常,解析失败"];
- }
- echo "<pre>";
- print_r($data);
- }else{
- $data = ['code'=>"error",'msg'=>"请输入抖音链接"];
- echo "<pre>";
- print_r($data);
- exit;
- }
- //网址转换
- function restoreUrl($shortUrl){
- $curl = curl_init();
- ...省略N行curl_setopt();
- $data = curl_exex($curl);
- $curlInfo = curl_getinfo($curl);
- curl_close($curl);
- if(in_array($curlInfo['http_code'],[301,302]) {
- return $curlInfo['redirect_url'];
- } else{
- return false;
- }
- }
上面代码比较简单,仅供基础学习。请勿因此侵犯抖音平台及其用户的相关权益。尊重知识,尊重他人。