Php 如何从last.fm api获取艺术家姓名

Php 如何从last.fm api获取艺术家姓名,php,json,api,last.fm,Php,Json,Api,Last.fm,我想从last.fm api中获取艺术家名称 这是一个密码 使用PHP的方法: 让我知道这是否有效,或者如果php需要调整,我现在没有php客户端。使用php的方法: 让我知道这是否有效,或者如果php需要调整,我现在没有php客户端。很酷,谢谢,我有正确的 from:$phpArtist=$phpJson['tracks']['track'][0]['artist'] 收件人:$Artist=$track['Artist']['name'] 而且很有效,谢谢你,很酷,谢谢你,我说得对 from

我想从last.fm api中获取艺术家名称 这是一个密码

使用PHP的方法:

让我知道这是否有效,或者如果php需要调整,我现在没有php客户端。

使用php的方法:

让我知道这是否有效,或者如果php需要调整,我现在没有php客户端。

很酷,谢谢,我有正确的 from:
$phpArtist=$phpJson['tracks']['track'][0]['artist']
收件人:
$Artist=$track['Artist']['name']
而且很有效,谢谢你,很酷,谢谢你,我说得对
from:
$phpArtist=$phpJson['tracks']['track'][0]['artist']
收件人:
$Artist=$track['Artist']['name']
谢谢,谢谢。请不要加上“谢谢”作为回答。相反,你应该接受解决问题的答案。当你有足够的声誉,你也可以或。请不要添加“谢谢”作为回答。相反,你应该接受解决问题的答案。当你有足够的声誉,你也可以或。
$jsonData = file_get_contents('http://ws.audioscrobbler.com/2.0/?method=chart.gettoptracks&limit=56&api_key=MYAPIKEY&format=json');
            $jsonData = json_decode($jsonData, true);
foreach ($jsonData['tracks']['track'] as $track) {
                $title = $track['name'];
                $image = $track['image'][3]['#text'];
                echo '<div id="track_short"><div class="track_short">
                <a href="http://'.$SiteUrl.'/mp3-download-'.cano($title).'/" ><img src="'.$image.'" alt="'.$title.'">
                <div class="description"><p class="description_content">'.$title.'</p>
                </div></a></div></div>';
}
{"tracks":{"track":[{"name":"Sorry","duration":"0","playcount":"1931615","listeners":"193074","mbid":"","url":"http://www.last.fm/music/Justin+Bieber/_/Sorry","streamable":{"#text":"0","fulltrack":"0"},"artist":{"name":"Justin Bieber","mbid":"e0140a67-e4d1-4f13-8a01-364355bee46e","url":"http://www.last.fm/music/Justin+Bieber"},"image":[{"#text":"http://img2-ak.lst.fm/i/u/34s/d5af34cbc048b190fc7369acdcf8655b.png","size":"small"},{"#text":"http://img2-ak.lst.fm/i/u/64s/d5af34cbc048b190fc7369acdcf8655b.png","size":"medium"},{"#text":"http://img2-ak.lst.fm/i/u/174s/d5af34cbc048b190fc7369acdcf8655b.png","size":"large"},{"#text":"http://img2-ak.lst.fm/i/u/300x300/d5af34cbc048b190fc7369acdcf8655b.png","size":"extralarge"}]}],"@attr":{"page":"1","perPage":"1","totalPages":"253572626","total":"253572626"}}}
$json = '{"tracks":{"track":[{"name":"Sorry","duration":"0","playcount":"1931615","listeners":"193074","mbid":"","url":"http://www.last.fm/music/Justin+Bieber/_/Sorry","streamable":{"#text":"0","fulltrack":"0"},"artist":{"name":"Justin Bieber","mbid":"e0140a67-e4d1-4f13-8a01-364355bee46e","url":"http://www.last.fm/music/Justin+Bieber"},"image":[{"#text":"http://img2-ak.lst.fm/i/u/34s/d5af34cbc048b190fc7369acdcf8655b.png","size":"small"},{"#text":"http://img2-ak.lst.fm/i/u/64s/d5af34cbc048b190fc7369acdcf8655b.png","size":"medium"},{"#text":"http://img2-ak.lst.fm/i/u/174s/d5af34cbc048b190fc7369acdcf8655b.png","size":"large"},{"#text":"http://img2-ak.lst.fm/i/u/300x300/d5af34cbc048b190fc7369acdcf8655b.png","size":"extralarge"}]}],"@attr":{"page":"1","perPage":"1","totalPages":"253572626","total":"253572626"}}}';
$phpJson = json_decode($json, true, 10); //4 is the depth of the JSON string, but you can make this a big number and it will still work
$phpArtist = $phpJson['tracks']['track'][0]['artist']['name'];