"QQ Music API" counter switch to build your own music station

Source: Internet
Author: User
Tags sprintf urlencode

A recent whim wants to make a small online music web page. The requirements are simple, as follows

    1. Search for songs or singers

    2. Play Music Online

    3. Borrowing QQ or Baidu's music interface

The demand is clear.

I first try the Baidu music, but can not play online (hint forbidden), although can not play online, but the download is possible


Baidu Music specific API is as follows

1: Search Interface

$url = "http://musicmini.baidu.com/app/search/searchList.php?qword=%s&ie=utf-8&page=1";// Qword is the song or singer to search for: sprintf ($url, UrlEncode ($kw));

This is not actually an interface, is a page of Baidu, directly can access


2: HTML string based on search result, then remove song_id, use regular expression

3: Get the song information according to SONG_ID, the interface is as follows

$url = "http://music.baidu.com/data/music/links?songIds=%s";//song_ids can accept multiple song_id, with "," split

According to the song_id in is 623748, the result is as follows (JSON), where

Songname: Song name

Artistname: Singer

Songpicbig: Song cover picture

Songlink: Song Address


Bao Jianfeng from the sharpening out of plum blossom from bitter cold, engaged in a long time to find even get the song address, can not play online, only the position, QQ music API is relatively friendly, song address is not limited to play, like a

QQ Music API needs to use the following interface

1: Search Interface

$url = "Http://s.music.qq.com/fcgi-bin/music_search_new_platform?t=0&n=%s&aggr=1&cr=1&loginUin=0 &format=json&inCharset=GB2312&outCharset=utf-8&notice=0&platform=jqminiframe.json& neednewcode=0&p=1&catzhida=0&remoteplace=sizer.newclient.next_song&w=%s "; $url = sprintf ($url, $ Page_size,urlencode ($kw));

Parameter n: Number of pages per page

Parameter w: Search for songs or singers

For example we search Faye Wong, 5 per page, the results are as follows (JSON)

Property F with "|" Split, there are two important values, where the red line is drawn

song_id: 1th, 104776135 in

image_id: 5th, 1181501 in


2: Find lyrics according to song_id

"http://music.qq.com/miniportal/static/lyric/". ($song _id%100). " /{$song _id}.xml ";

One of these parameters is based on the song_id mo

3: Find the song cover picture according to IMAGE_ID

"Http://imgcache.qq.com/music/photo/album_{$width}/". ($image _id%100). " /{$width}_albumpic_{$image _id}_0.jpg ";

One of the parameters is also based on the image_id mo

Width parameter to specify picture widths


4: Find song address according to SONG_ID

"Http://tsmusic24.tc.qq.com/{$song _id}.mp3"


According to the above 4 steps go, OK


Online music website display, also can try online: QQ Music Resource Search



Service Number (imguowei_888) song function



Interested in can follow my service number play


PS: My own implementation of the music site, or use an interface, is based on song_id to get the details of the song, because people are blocked, if someone needs please contact me directly

I have referred to another public number in the course of implementation. WeChat song: Vdiange


The original address: "QQ Music API" counter switch to create their own music radio

"QQ Music API" counter switch to build your own music station

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.