{ "ext": "mp4", "msg": "200", "url": "http:\/\/v.yinyuetai.com\/video\/3372061", "MV": "http:\/\/hc.yinyuetai.com\/uploads\/videos\/common\/B1390169F65AF6ACB8F92FAA4B7984F4.mp4?scu003d63489042562d6927u0026bru003d782u0026vidu003d3372061u0026aidu003d16147u0026areau003dMLu0026vstu003d3", "img": "\/\/img1.c.yinyuetai.com\/video\/mv\/190407\/0\/7005cc0953dce254b7970b6893e2f4c3_240x135.jpg" }
<?php /** * Created by PhpStorm. * User: FZS * Time: 2019/3/15 17:50 */ //---------------------------------- // 小明API 音悦tai搜索 调用类 //---------------------------------- class freeApi{ private $apiUrl = 'http://api.guaqb.cn/music/tai.php?url=我爱你'; /** * 获取结果 * @return array */ public function getResult(){ return $this->freeApiCurl($this->apiUrl); } /** * 请求接口返回内容 * @param string $url [请求的URL地址] * @param string $params [请求的参数] * @param int $ipost [是否采用POST形式] * @return string */ public function freeApiCurl($url,$params=false,$ispost=0){ $ch = curl_init(); curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 ); curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 ); curl_setopt( $ch, CURLOPT_USERAGENT , 'free-api' ); curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT , 60 ); curl_setopt( $ch, CURLOPT_TIMEOUT , 60); curl_setopt( $ch, CURLOPT_RETURNTRANSFER , true ); if( $ispost ) { curl_setopt( $ch , CURLOPT_POST , true ); curl_setopt( $ch , CURLOPT_POSTFIELDS , $params ); curl_setopt( $ch , CURLOPT_URL , $url ); } else { if($params){ curl_setopt( $ch , CURLOPT_URL , $url.'?'.$params ); }else{ curl_setopt( $ch , CURLOPT_URL , $url); } } $response = curl_exec( $ch ); if ($response === FALSE) { return false; } curl_close( $ch ); return $response; } } $api = new freeApi(); var_dump($api->getResult());