本篇文章主要介绍php通过新浪乐库搜索接口查询歌曲的功能,感兴趣的朋友参考下,希望对大家有所帮助。
具体如下:
<form name="" method="post" action="">
<input name="key" type="text" /> <input name="submit" type="submit" value="搜歌" />
</form>
<pre>
<?php
header('meta http-equiv="content-type"content="text/html; charset=gb2312"');
if( isset( $_REQUEST['submit']) && isset( $_REQUEST['key']))
$key = $_REQUEST['key'];
else $key = '周杰伦';
$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';
?>
</pre>
<?php foreach( $data as $one){
$music = $one->MP3URL;
$music = file_get_contents( $music);
$music = str_replace('iask_music_song_url="' , '', str_replace('";' , '', $music));
?>
<p><?php echo 'ALBUM_NAME : '.$one->NAME.' MUSIC_URL : <a href='.$music.'>'.$one->NAME.'</a>'.' SINGER_NAME'.$one->SINGERCNAME;?></p>
<?php }
?>总结:以上就是本篇文的全部内容,希望能对大家的学习有所帮助。
相关推荐:
立即学习“PHP免费学习笔记(深入)”;
以上就是php通过新浪乐库搜索接口查询歌曲的功能的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号