This article mainly introduces the PHP method for simple song searching. The example analyzes the function of php to query songs through the search interface of Sina Music Library, which has some reference value, for more information, see the example in this article. Share it with you for your reference. The specific implementation method is as follows:
<? Php header ('meta http-equiv = "content-type" content = "text/html; charset = gb2312 "'); if (isset ($ _ REQUEST ['submit ']) & isset ($ _ REQUEST ['key']) $ key = $ _ REQUEST ['key']; else $ key = 'Jay Chou '; $ url = 'http: // music.sina.com.cn/yueku/search/getRecommendXml1dot0.php? Q = '. urlencode ($ key ). '& l = 50 & json = json'; $ data = file_get_contents ($ url); $ data = json_decode ($ data); if (! Count ($ data) echo 'not found ';?>
<? Php foreach ($ data as $ one) {$ music = $ one-> MP3URL; $ music = file_get_contents ($ music ); $ music = str_replace ('iask _ music_song_url = "','', str_replace (' "; ','', $ music);?><? Php echo 'Album _ NAME :'. $ one-> NAME. 'music_url :'. $ one-> NAME. ''. 'singer_name '. $ one-> SINGERCNAME;?>
<? Php }?>
I hope this article will help you with php programming.