我已经有了这个脚本来保存从Deezer到我的服务器的albumart。 albumart的网址没问题,你可以试试看。它确实创建了一个文件,但它不是我想看到的图像,而是一个损坏的文件。我猜测它与你在访问你从API获得的原始链接时提供的(我猜)301有关。但如果是这样的话,我不知道解决这个问题的热点。Deezer API和file_put_contents
<?php
// Deezer
$query = 'https://api.deezer.com/2.0/search?q=madonna';
$file = file_get_contents($query);
$parsedFile = json_decode($file);
$albumart = $parsedFile->data[0]->artist->picture;
$artist = $parsedFile->data[0]->artist->name;
$dir = dirname(__FILE__).'/albumarts/'.$artist.'.jpg';
file_put_contents($dir, $albumart);
?>