Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用Last.fm API(需要示例)PHP获取艺术家的所有图像_Javascript_Php - Fatal编程技术网

Javascript 如何使用Last.fm API(需要示例)PHP获取艺术家的所有图像

Javascript 如何使用Last.fm API(需要示例)PHP获取艺术家的所有图像,javascript,php,Javascript,Php,$returnedInfo=”“。self::API_键。“&artist=”$艺术家“&album=”$专辑“&image=”。self::$size\u map[$size]。“&format=json” $htmlContent=文件获取内容('.$artist./+images') // We'll add all the images in this array $images = array(); // Instantiate a new object of class DOMDo

$returnedInfo=”“。self::API_键。“&artist=”$艺术家“&album=”$专辑“&image=”。self::$size\u map[$size]。“&format=json”

$htmlContent=文件获取内容('.$artist./+images')

// We'll add all the images in this array
$images = array();

// Instantiate a new object of class DOMDocument
$doc = new DOMDocument();

// Load the HTML doc into the object
libxml_use_internal_errors(true);
$doc->loadHTML($htmlContent);
libxml_use_internal_errors(false);

// Get all the IMG tags in the document
$elements = $doc->getElementsByTagName('img');

// If we get at least one result
if($elements->length > 0)
{
   // Loop on all of the IMG tags
   foreach($elements as $element)
   {
      // Get the attribute SRC of the IMG tag (this is the link of the image)
      $src = $element->getAttribute('src');

      if (strlen($src) > 0) {
        // Add the link to the array containing all the links
        array_push($images, $src);
      }

   }