酷狗铃声解析接口PHP源码

简介

酷狗铃声解析接口
图片[1]-酷狗铃声解析接口PHP源码-小白资源博客-个人技术分享

代码

<?php

 
header("content-type:application/json; charset=utf-8");

$text = $_GET['text'];

if (empty($text)) {
	echo json_encode(['code' => 1, 'msg' => '搜索铃声名不能为空'], 320);
	exit;
}

$data = json_decode(curl('http://api.ring.kugou.com/ring/all_search?q='.$text.'&t=3&subtype=1&p=1&pn=50&plat=3'),true);

foreach($data['response']['musicInfo'] as $k=>$v){
$array[] = array(
    'ring_name'=>$v ['ringName'],//铃声名
    'singer_name'=>$v ['singerName'],//歌手
    'musiclink'=>$v ['url']);//铃声直链
}

$value = [
    'code' => 200,
    'msg'  => '请求成功',
    'data' =>$array];

echo json_encode($value,460);

function curl($url){ //Curl GET
    $ch = curl_init();     // Curl 初始化  
    $timeout = 30;     // 超时时间:30s  
    $ua='Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36';// 伪造抓取 UA  
    $ip = mt_rand(11, 191) . "." . mt_rand(0, 240) . "." . mt_rand(1, 240) . "." . mt_rand(1, 240);
    curl_setopt($ch, CURLOPT_URL, $url);// 设置 Curl 目标  
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);// Curl 请求有返回的值  
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);// 设置抓取超时时间  
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// 跟踪重定向  
    curl_setopt($ch, CURLOPT_REFERER, 'https://www.baidu.com/');//模拟来路
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-FORWARDED-FOR:'.$ip, 'CLIENT-IP:'.$ip));  //伪造IP  
    curl_setopt($ch, CURLOPT_USERAGENT, $ua);// 伪造ua   
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);// https请求 不验证证书和hosts  
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);  
    curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);//强制协议为1.0
    curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );//强制使用IPV4协议解析域名
    $content = curl_exec($ch);   
    curl_close($ch);// 结束 Curl  
    return $content;// 函数返回内容  
}

教程

域名/目录?text=画

下载

蓝奏云 :https://yxyp.lanzouy.com/im32k0bebnwh


小白资源博客-个人技术分享,原文地址: https://www.yxyp.cc/132
© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片