<code><?php
$url
=
'http://music.163.com/api/playlist/detail?id=92664101'
;
$json
=
file_get_contents
(
$url
);
$obj
= json_decode(
$json
);
if
(!
is_object
(
$obj
) ||
$obj
->code != 200) {
exit
(
'fetch data fail'
);
}
$result
=
$obj
->result;
?>
<meta charset=
"UTF-8"
>
<title>netease JSON parse</title>
<meta name=
"viewport"
content=
"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
>
<link href=
"http://libs.baidu.com/bootstrap/3.0.3/css/bootstrap.min.css"
rel=
"stylesheet"
>
<link href=
"http://www.bootcss.com/p/flat-ui/css/flat-ui.css"
rel=
"stylesheet"
>
<link rel=
"shortcut icon"
href=
"http://a.tbcdn.cn/s/kissy/favicon.ico"
type=
"image/x-icon"
>
<div
class
=
"container"
>
<h1
class
=
"page-header"
>
<?php
echo
$result
->creator->nickname;?><small>avatarUrl:<?php
echo
$result
->creator->avatarUrl;?></small>
</h1>
<div
class
=
"row"
>
<?php
if
(
count
(
$result
->tracks)){?>
<table
class
=
"table table-striped"
>
<thead>
<tr>
<th>#</th>
<th>歌曲标题</th>
<th>时长</th>
<th>歌手</th>
<th>mp3Url</th>
<th>picUrl</th>
</tr>
</thead>
<tbody>
<?php
foreach
(
$result
->tracks
as
$key
=>
$row
){?>
<tr>
<th><?php
echo
$key
;?></th>
<th>
<?php
echo
$row
->name;?></th>
<th>
<?php
echo
$row
->duration/1000;?>s</th>
<th>
<?php
echo
$row
->artists[0]->name;?></th>
<th><a href=
"<?php%20echo%20%24row->mp3Url;?>"
target=
"_blank"
>播放链接</a></th>
<th><a href=
"<?php%20echo%20%24row->album->picUrl;?>"
target=
"_blank"
>picUrl</a></th>
</tr>
<?php }?>
</tbody>
</table>
<?php }?>
</div>
</div>
</code>