2 回答
TA贡献1875条经验 获得超5个赞
响应包含一些必须删除才能解析 json 的 HTML。这可以通过strip_tags. 删除 html 后json_decode可用于获取值:
<?php
$content = file_get_contents('https://www.jiosaavn.com/api.php?_format=json&query=mere%20angne%20mein&__call=autocomplete.get');
$content = strip_tags($content);
$response = json_decode($content);
print_r($response);
foreach($response->albums->data as $album){
echo $album->title;
}
结果:
Mere Angne MeinLaawarisMere Angne MeinMere Angne Mein(来自“Mere Angne Mein”)Mere Angane Mein
TA贡献1829条经验 获得超9个赞
$url = 'https://www.jiosaavn.com/api.php_format=json&query=mere%20angne%20mein&__call=autocomplete.get';
$data = file_get_contents($url);
$format = json_decode($data);
print_r($format);
- 2 回答
- 0 关注
- 116 浏览
添加回答
举报