您所在的位置:小祥子 » 编程 » JavaScript » 正文

百度音乐API接口

时间:2015-06-05 编辑:wanglisheng 来源:本站整理

如 xml格式:
http://mp3.baidu.com/dev/api/?tn=getinfo&ct=0&word=%E6%B5%81%E6%B5%AA%E8%AE%B0&ie=utf-8&format=xml

返回:

<res>
<song><![CDATA[流浪记]]></song>
<song_id><![CDATA[38233821]]></song_id>
<singer><![CDATA[杨宗纬]]></singer>
<album><![CDATA[我是歌手 第十一期]]></album>
<singerPicLarge><![CDATA[http://qukufile2.qianqian.com/data2/pic/36218335/36218335.jpg]]></singerPicLarge>
<singerPicSmall><![CDATA[http://qukufile2.qianqian.com/data2/pic/36218344/36218344.jpg]]></singerPicSmall>
<albumPicLarge><![CDATA[]]></albumPicLarge>
<albumPicSmall><![CDATA[]]></albumPicSmall>
</res>

JSon格式:http://mp3.baidu.com/dev/api/?tn=getinfo&ct=0&word=%E6%B5%81%E6%B5%AA%E8%AE%B0&ie=utf-8&format=json

返回:

{
"song": "\u6d41\u6d6a\u8bb0",
"song_id": "38233821",
"singer": "\u6768\u5b97\u7eac",
"album": "\u6211\u662f\u6b4c\u624b \u7b2c\u5341\u4e00\u671f",
"singerPicSmall": "http:\/\/qukufile2.qianqian.com\/data2\/pic\/36218344\/36218344.jpg",
"singerPicLarge": "http:\/\/qukufile2.qianqian.com\/data2\/pic\/36218335\/36218335.jpg",
"albumPicLarge": "",
"albumPicSmall": ""
}

2、通过歌曲id (song_id) 获取歌曲下载地址:
http://ting.baidu.com/data/music/links?songIds=<songIds>
GET 方式获取:
参数:

    songIds: "38233821" //歌曲id,从第1个列表中得到的歌曲id  

    callback: "callback" //不为空时,返回jsonp格式数据

如:http://ting.baidu.com/data/music/links?songIds=38233821

返回:

{
"errorCode": 22000,
"data": {
"xcode": "808f67065a7ea25b17e77954bed13215",
"songList": [{
"queryId": "38233821",
"songId": 38233821,
"songName": "\u6d41\u6d6a\u8bb0",
"artistId": "8477",
"artistName": "\u6768\u5b97\u7eac",
"albumId": 38233662,
"albumName": "\u6211\u662f\u6b4c\u624b \u7b2c\u5341\u4e00\u671f",
"songPicSmall": "http:\/\/c.hiphotos.baidu.com\/ting\/pic\/item\/29381f30e924b899d068ee4b6f061d950a7bf669.jpg",
"songPicBig": "http:\/\/c.hiphotos.baidu.com\/ting\/pic\/item\/2f738bd4b31c8701d1e22595267f9e2f0708ff69.jpg",
"songPicRadio": "http:\/\/c.hiphotos.baidu.com\/ting\/pic\/item\/b21bb051f81986185f1378f74bed2e738bd4e669.jpg",
"lrcLink": "\/data2\/lrc\/38238568\/38238568.lrc",
"version": "\u73b0\u573a",
"copyType": 1,
"time": 309,
"linkCode": 22000,
"songLink": "http:\/\/zhangmenshiting.baidu.com\/data2\/music\/38542270\/382338211365422461.mp3",
"showLink": "http:\/\/zhangmenshiting.baidu.com\/data2\/music\/38542270\/382338211365422461.mp3?xcode=808f67065a7ea25b17e77954bed13215",
"format": "mp3",
"rate": 128,
"size": 4984113,
"relateStatus": "0",
"resourceType": "0"
}]
}
}

注意:mp3下载地址为 songLink,后面加xcode参数,xcode每秒自动更新一次。

关键词:音乐 API