[源码]随机获取虾米音乐song_id API文件

January 11, 2015

[源码]随机获取虾米音乐song_id API文件-LMLPHP

  1. <?php
  2. $url = file_get_contents('http://www.xiami.com/search/song/page/'.rand(1,636).'?key=%E5%8A%A8%E6%BC%AB&is_pub=y');
  3. preg_match_all("/\?sid=(\d+)/", $url, $song);
  4. if($_GET){
  5. echo $_GET['callback'].'('.json_encode(array("song_id"=>$song[1][rand(0,19)])).')';
  6. }else{
  7. echo json_encode(array("song_id"=>$song[1][rand(0,19)]));
  8. }
05-07 15:15