码迷,mamicode.com
首页 > 其他好文 > 详细

百度随心听

时间:2015-06-12 17:04:33      阅读:107      评论:0      收藏:0      [点我收藏+]

标签:

<?php
    /*
    频道列表url fm.baidu.com/dev/api/?tn=channellist
    */ 
    $url1="http://fm.baidu.com/dev/api/?tn=playlist&id=public_xinqing_shanggan";
    $res1=json_decode(file_get_contents($url1),true);
    $name=$res1[‘channel_name‘];
    foreach( $res1[‘list‘] as $key => $value )
    {
        $data[‘songids‘].=$res1[‘list‘][$key][‘id‘].",";
    }
    
    $url2="http://fm.baidu.com/data/music/songlink"; 
    echo https_request($url2,$data);die(); 
    
    
     function https_request($url, $data = null)
     {
         $curl = curl_init();
         curl_setopt($curl, CURLOPT_URL, $url);
         curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
         curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
         if (!empty($data)){
             curl_setopt($curl, CURLOPT_POST, 1);
             curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
         }
         curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
         $output = curl_exec($curl);
         curl_close($curl);
         return $output;
     }
?>

 

百度随心听

标签:

原文地址:http://www.cnblogs.com/yutaoyao/p/4571773.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!