2 回答

TA貢獻(xiàn)1875條經(jīng)驗(yàn) 獲得超5個(gè)贊
響應(yīng)包含一些必須刪除才能解析 json 的 HTML。這可以通過(guò)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;
}
結(jié)果:
Mere Angne MeinLaawarisMere Angne MeinMere Angne Mein(來(lái)自“Mere Angne Mein”)Mere Angane Mein

TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超9個(gè)贊
$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 關(guān)注
- 166 瀏覽
添加回答
舉報(bào)