我想用php输出我在网易云音乐的歌单内容,先使用一个foreach输出歌单名称和id,再使用上一次输出的id来输出歌单内容。但是输出歌单内容就不知道该怎样写了...求大神帮助
<?php
header('Content-type: application/json');
header("Content-type: text/html; charset=utf-8");
$refer = "http://music.163.com/";
$header[] = "Cookie: " . "appver=1.5.0.75771;";
$url = "http://music.163.com/api/user/playlist/?offset=0&limit=1001&uid=52792247";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
curl_setopt($ch, CURLOPT_REFERER, $refer);
$cexecute = curl_exec($ch);
curl_close($ch);
$obj = json_decode($cexecute);
$result = $obj->playlist;
foreach($result as $row){
echo $row->name;
echo $row->id;
echo $row->coverImgUrl;
}
?>
上面的代码可以正常输出,在有多个id的情况下该怎样循环输出http://music.163.com/api/playlist/detail?id=刚刚输出的id
的内容?
又是你!!!
获取用户歌单列表的API是POST请求,且参数做了加密,参考这里,这里就不深入了