View image (from web api) without extension in php [closed]

0

I'm accessing the web api spotify and extracting the images from the albums, the problem is that so far the code is static and to insert images quietly with the following method:

<style type='text/css'> 

    h1 {  background-image: url($img);
          width: 50%;
          height: 50%;
          margin: 2%;
          font-size: 0px;
    }

</style>

But it is not possible to insert the image with the tag <img scr='$nome' ... > or <h1 style=' background-image: url($nome)'> (when I tried to insert with these two methods nothing was presented, not even in the log of php -S localhost:8000 ) and it would be complicated to insert with the method that it worked out when I was going to make it very dynamic, so would anyone have any tips / hints what I might be doing wrong so I can solve it?

After filtering on the api I get the following url (This code is what goes into the variable I used in the first example : $ img).

I searched the php site, site point , byte , w3schools , among others. nothing.

    
asked by anonymous 24.01.2017 / 05:27

1 answer

1

There is no problem in including the URL directly in the <img> element, the image in this case is just text, does not require any processing or rendering or use of any other library for image manipulation.

Making a CURL, as documented by Spotify:

curl -X GET "https://api.spotify.com/v1/albums/4P5nTTfGxuCGZDHzT9DPAh" -H "Accept: application/json"
  

Remembering that this can usually be done by using PHP CURL fault, see here. : / p>

$ch = curl_init('https://api.spotify.com/v1/albums/4P5nTTfGxuCGZDHzT9DPAh');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true, 
    CURLOPT_HTTPHEADER => [
       'Accept: application/json'
    ]
]);
$html = curl_exec($ch);
curl_close($ch);

You will get this:

{
  "album_type" : "album",
  "artists" : [ {
    "external_urls" : {
      "spotify" : "https://open.spotify.com/artist/6qJ61DomA73g7jQEKESw9Z"
    },
    "href" : "https://api.spotify.com/v1/artists/6qJ61DomA73g7jQEKESw9Z",
    "id" : "6qJ61DomA73g7jQEKESw9Z",
    "name" : "Noisecontrollers",
    "type" : "artist",
    "uri" : "spotify:artist:6qJ61DomA73g7jQEKESw9Z"
  }, {
    "external_urls" : {
      "spotify" : "https://open.spotify.com/artist/1Uk4IDpF1OIuTzANugS5JC"
    },
    "href" : "https://api.spotify.com/v1/artists/1Uk4IDpF1OIuTzANugS5JC",
    "id" : "1Uk4IDpF1OIuTzANugS5JC",
    "name" : "Bass Modulators",
    "type" : "artist",
    "uri" : "spotify:artist:1Uk4IDpF1OIuTzANugS5JC"
  } ],
  "available_markets" : [ "AD", "AR", "AT", "AU", "BE", "BG", "BO", "BR", "CA", "CH", "CL", "CO", "CR", "CY", "CZ", "DE", "DK", "DO", "EC", "EE", "ES", "FI", "FR", "GB", "GR", "GT", "HK", "HN", "HU", "ID", "IE", "IS", "IT", "JP", "LI", "LT", "LU", "LV", "MC", "MT", "MX", "MY", "NI", "NL", "NO", "NZ", "PA", "PE", "PH", "PL", "PT", "PY", "SE", "SG", "SK", "SV", "TR", "TW", "US", "UY" ],
  "copyrights" : [ {
    "text" : "2016 Headliner Music / Q-dance Records",
    "type" : "C"
  }, {
    "text" : "2016 Headliner Music / Q-dance Records",
    "type" : "P"
  } ],
  "external_ids" : {
    "upc" : "8719244840809"
  },
  "external_urls" : {
    "spotify" : "https://open.spotify.com/album/4P5nTTfGxuCGZDHzT9DPAh"
  },
  "genres" : [ ],
  "href" : "https://api.spotify.com/v1/albums/4P5nTTfGxuCGZDHzT9DPAh",
  "id" : "4P5nTTfGxuCGZDHzT9DPAh",
  "images" : [ {
    "height" : 640,
    "url" : "https://i.scdn.co/image/f7a13856ec2ce599e86c092d1caefc880fea5fbd",
    "width" : 640
  }, {
    "height" : 300,
    "url" : "https://i.scdn.co/image/ee0851dd12d9a73230af5db12a3be94ac36158d3",
    "width" : 300
  }, {
    "height" : 64,
    "url" : "https://i.scdn.co/image/a315d40a1ed29a3a17d858cfb7de4c99a4aba59a",
    "width" : 64
  } ],
  "label" : "Q-dance Records",
  "name" : "Chapter One",
  "popularity" : 53,
  "release_date" : "2016-07-15",
  "release_date_precision" : "day",
  "tracks" : {
    "href" : "https://api.spotify.com/v1/albums/4P5nTTfGxuCGZDHzT9DPAh/tracks?offset=0&limit=50",
    "items" : [ {
      "artists" : [ {
        "external_urls" : {
          "spotify" : "https://open.spotify.com/artist/6qJ61DomA73g7jQEKESw9Z"
        },
        "href" : "https://api.spotify.com/v1/artists/6qJ61DomA73g7jQEKESw9Z",
        "id" : "6qJ61DomA73g7jQEKESw9Z",
        "name" : "Noisecontrollers",
        "type" : "artist",
        "uri" : "spotify:artist:6qJ61DomA73g7jQEKESw9Z"
      }, {
        "external_urls" : {
          "spotify" : "https://open.spotify.com/artist/1Uk4IDpF1OIuTzANugS5JC"
        },
        "href" : "https://api.spotify.com/v1/artists/1Uk4IDpF1OIuTzANugS5JC",
        "id" : "1Uk4IDpF1OIuTzANugS5JC",
        "name" : "Bass Modulators",
        "type" : "artist",
        "uri" : "spotify:artist:1Uk4IDpF1OIuTzANugS5JC"
      } ],
      "available_markets" : [ "AD", "AR", "AT", "AU", "BE", "BG", "BO", "BR", "CA", "CH", "CL", "CO", "CR", "CY", "CZ", "DE", "DK", "DO", "EC", "EE", "ES", "FI", "FR", "GB", "GR", "GT", "HK", "HN", "HU", "ID", "IE", "IS", "IT", "JP", "LI", "LT", "LU", "LV", "MC", "MT", "MX", "MY", "NI", "NL", "NO", "NZ", "PA", "PE", "PH", "PL", "PT", "PY", "SE", "SG", "SK", "SV", "TR", "TW", "US", "UY" ],
      "disc_number" : 1,
      "duration_ms" : 274504,
      "explicit" : false,
      "external_urls" : {
        "spotify" : "https://open.spotify.com/track/0ALNZS8aM3SUaqPeis0ADs"
      },
      "href" : "https://api.spotify.com/v1/tracks/0ALNZS8aM3SUaqPeis0ADs",
      "id" : "0ALNZS8aM3SUaqPeis0ADs",
      "name" : "Solar - Sogma Edit",
      "preview_url" : "https://p.scdn.co/mp3-preview/d91848eb2b61576536eaf6b2b18ef4f6817c73fd?cid=null",
      "track_number" : 1,
      "type" : "track",
      "uri" : "spotify:track:0ALNZS8aM3SUaqPeis0ADs"
    }, {
      "artists" : [ {
        "external_urls" : {
          "spotify" : "https://open.spotify.com/artist/6qJ61DomA73g7jQEKESw9Z"
        },
        "href" : "https://api.spotify.com/v1/artists/6qJ61DomA73g7jQEKESw9Z",
        "id" : "6qJ61DomA73g7jQEKESw9Z",
        "name" : "Noisecontrollers",
        "type" : "artist",
        "uri" : "spotify:artist:6qJ61DomA73g7jQEKESw9Z"
      }, {
        "external_urls" : {
          "spotify" : "https://open.spotify.com/artist/1Uk4IDpF1OIuTzANugS5JC"
        },
        "href" : "https://api.spotify.com/v1/artists/1Uk4IDpF1OIuTzANugS5JC",
        "id" : "1Uk4IDpF1OIuTzANugS5JC",
        "name" : "Bass Modulators",
        "type" : "artist",
        "uri" : "spotify:artist:1Uk4IDpF1OIuTzANugS5JC"
      } ],
      "available_markets" : [ "AD", "AR", "AT", "AU", "BE", "BG", "BO", "BR", "CA", "CH", "CL", "CO", "CR", "CY", "CZ", "DE", "DK", "DO", "EC", "EE", "ES", "FI", "FR", "GB", "GR", "GT", "HK", "HN", "HU", "ID", "IE", "IS", "IT", "JP", "LI", "LT", "LU", "LV", "MC", "MT", "MX", "MY", "NI", "NL", "NO", "NZ", "PA", "PE", "PH", "PL", "PT", "PY", "SE", "SG", "SK", "SV", "TR", "TW", "US", "UY" ],
      "disc_number" : 1,
      "duration_ms" : 206515,
      "explicit" : false,
      "external_urls" : {
        "spotify" : "https://open.spotify.com/track/7BDzpOG4JFka6ab0O1jn8k"
      },
      "href" : "https://api.spotify.com/v1/tracks/7BDzpOG4JFka6ab0O1jn8k",
      "id" : "7BDzpOG4JFka6ab0O1jn8k",
      "name" : "See The Light",
      "preview_url" : "https://p.scdn.co/mp3-preview/37f71724ea8ca1678a7460a8d2d574c30e81da74?cid=null",
      "track_number" : 2,
      "type" : "track",
      "uri" : "spotify:track:7BDzpOG4JFka6ab0O1jn8k"
    }, {
      "artists" : [ {
        "external_urls" : {
          "spotify" : "https://open.spotify.com/artist/6qJ61DomA73g7jQEKESw9Z"
        },
        "href" : "https://api.spotify.com/v1/artists/6qJ61DomA73g7jQEKESw9Z",
        "id" : "6qJ61DomA73g7jQEKESw9Z",
        "name" : "Noisecontrollers",
        "type" : "artist",
        "uri" : "spotify:artist:6qJ61DomA73g7jQEKESw9Z"
      }, {
        "external_urls" : {
          "spotify" : "https://open.spotify.com/artist/1Uk4IDpF1OIuTzANugS5JC"
        },
        "href" : "https://api.spotify.com/v1/artists/1Uk4IDpF1OIuTzANugS5JC",
        "id" : "1Uk4IDpF1OIuTzANugS5JC",
        "name" : "Bass Modulators",
        "type" : "artist",
        "uri" : "spotify:artist:1Uk4IDpF1OIuTzANugS5JC"
      } ],
      "available_markets" : [ "AD", "AR", "AT", "AU", "BE", "BG", "BO", "BR", "CA", "CH", "CL", "CO", "CR", "CY", "CZ", "DE", "DK", "DO", "EC", "EE", "ES", "FI", "FR", "GB", "GR", "GT", "HK", "HN", "HU", "ID", "IE", "IS", "IT", "JP", "LI", "LT", "LU", "LV", "MC", "MT", "MX", "MY", "NI", "NL", "NO", "NZ", "PA", "PE", "PH", "PL", "PT", "PY", "SE", "SG", "SK", "SV", "TR", "TW", "US", "UY" ],
      "disc_number" : 1,
      "duration_ms" : 163200,
      "explicit" : false,
      "external_urls" : {
        "spotify" : "https://open.spotify.com/track/4aIZThq1DLsalslK3bJeAC"
      },
      "href" : "https://api.spotify.com/v1/tracks/4aIZThq1DLsalslK3bJeAC",
      "id" : "4aIZThq1DLsalslK3bJeAC",
      "name" : "Holding On",
      "preview_url" : "https://p.scdn.co/mp3-preview/7111a4b3910e0912f0dec2b627e9217eb115048a?cid=null",
      "track_number" : 3,
      "type" : "track",
      "uri" : "spotify:track:4aIZThq1DLsalslK3bJeAC"
    }, {
      "artists" : [ {
        "external_urls" : {
          "spotify" : "https://open.spotify.com/artist/6qJ61DomA73g7jQEKESw9Z"
        },
        "href" : "https://api.spotify.com/v1/artists/6qJ61DomA73g7jQEKESw9Z",
        "id" : "6qJ61DomA73g7jQEKESw9Z",
        "name" : "Noisecontrollers",
        "type" : "artist",
        "uri" : "spotify:artist:6qJ61DomA73g7jQEKESw9Z"
      }, {
        "external_urls" : {
          "spotify" : "https://open.spotify.com/artist/1Uk4IDpF1OIuTzANugS5JC"
        },
        "href" : "https://api.spotify.com/v1/artists/1Uk4IDpF1OIuTzANugS5JC",
        "id" : "1Uk4IDpF1OIuTzANugS5JC",
        "name" : "Bass Modulators",
        "type" : "artist",
        "uri" : "spotify:artist:1Uk4IDpF1OIuTzANugS5JC"
      } ],
      "available_markets" : [ "AD", "AR", "AT", "AU", "BE", "BG", "BO", "BR", "CA", "CH", "CL", "CO", "CR", "CY", "CZ", "DE", "DK", "DO", "EC", "EE", "ES", "FI", "FR", "GB", "GR", "GT", "HK", "HN", "HU", "ID", "IE", "IS", "IT", "JP", "LI", "LT", "LU", "LV", "MC", "MT", "MX", "MY", "NI", "NL", "NO", "NZ", "PA", "PE", "PH", "PL", "PT", "PY", "SE", "SG", "SK", "SV", "TR", "TW", "US", "UY" ],
      "disc_number" : 1,
      "duration_ms" : 205200,
      "explicit" : false,
      "external_urls" : {
        "spotify" : "https://open.spotify.com/track/4VeuVtTmOlr3ochwLvCeb4"
      },
      "href" : "https://api.spotify.com/v1/tracks/4VeuVtTmOlr3ochwLvCeb4",
      "id" : "4VeuVtTmOlr3ochwLvCeb4",
      "name" : "Glitch",
      "preview_url" : "https://p.scdn.co/mp3-preview/78bbc12a4c223e89f30825a046b4e4e918d851d2?cid=null",
      "track_number" : 4,
      "type" : "track",
      "uri" : "spotify:track:4VeuVtTmOlr3ochwLvCeb4"
    }, {
      "artists" : [ {
        "external_urls" : {
          "spotify" : "https://open.spotify.com/artist/6qJ61DomA73g7jQEKESw9Z"
        },
        "href" : "https://api.spotify.com/v1/artists/6qJ61DomA73g7jQEKESw9Z",
        "id" : "6qJ61DomA73g7jQEKESw9Z",
        "name" : "Noisecontrollers",
        "type" : "artist",
        "uri" : "spotify:artist:6qJ61DomA73g7jQEKESw9Z"
      }, {
        "external_urls" : {
          "spotify" : "https://open.spotify.com/artist/1Uk4IDpF1OIuTzANugS5JC"
        },
        "href" : "https://api.spotify.com/v1/artists/1Uk4IDpF1OIuTzANugS5JC",
        "id" : "1Uk4IDpF1OIuTzANugS5JC",
        "name" : "Bass Modulators",
        "type" : "artist",
        "uri" : "spotify:artist:1Uk4IDpF1OIuTzANugS5JC"
      } ],
      "available_markets" : [ "AD", "AR", "AT", "AU", "BE", "BG", "BO", "BR", "CA", "CH", "CL", "CO", "CR", "CY", "CZ", "DE", "DK", "DO", "EC", "EE", "ES", "FI", "FR", "GB", "GR", "GT", "HK", "HN", "HU", "ID", "IE", "IS", "IT", "JP", "LI", "LT", "LU", "LV", "MC", "MT", "MX", "MY", "NI", "NL", "NO", "NZ", "PA", "PE", "PH", "PL", "PT", "PY", "SE", "SG", "SK", "SV", "TR", "TW", "US", "UY" ],
      "disc_number" : 1,
      "duration_ms" : 183200,
      "explicit" : false,
      "external_urls" : {
        "spotify" : "https://open.spotify.com/track/2KSn8bQzCL5UGB3JAgapVK"
      },
      "href" : "https://api.spotify.com/v1/tracks/2KSn8bQzCL5UGB3JAgapVK",
      "id" : "2KSn8bQzCL5UGB3JAgapVK",
      "name" : "Het Gevoel Van",
      "preview_url" : "https://p.scdn.co/mp3-preview/5f3bc9c84ccb48505f511ee6ef6cc690483d9f5d?cid=null",
      "track_number" : 5,
      "type" : "track",
      "uri" : "spotify:track:2KSn8bQzCL5UGB3JAgapVK"
    }, {
      "artists" : [ {
        "external_urls" : {
          "spotify" : "https://open.spotify.com/artist/6qJ61DomA73g7jQEKESw9Z"
        },
        "href" : "https://api.spotify.com/v1/artists/6qJ61DomA73g7jQEKESw9Z",
        "id" : "6qJ61DomA73g7jQEKESw9Z",
        "name" : "Noisecontrollers",
        "type" : "artist",
        "uri" : "spotify:artist:6qJ61DomA73g7jQEKESw9Z"
      } ],
      "available_markets" : [ "AD", "AR", "AT", "AU", "BE", "BG", "BO", "BR", "CA", "CH", "CL", "CO", "CR", "CY", "CZ", "DE", "DK", "DO", "EC", "EE", "ES", "FI", "FR", "GB", "GR", "GT", "HK", "HN", "HU", "ID", "IE", "IS", "IT", "JP", "LI", "LT", "LU", "LV", "MC", "MT", "MX", "MY", "NI", "NL", "NO", "NZ", "PA", "PE", "PH", "PL", "PT", "PY", "SE", "SG", "SK", "SV", "TR", "TW", "US", "UY" ],
      "disc_number" : 1,
      "duration_ms" : 184200,
      "explicit" : false,
      "external_urls" : {
        "spotify" : "https://open.spotify.com/track/2FgdtvJlotRv6uPHLV05B0"
      },
      "href" : "https://api.spotify.com/v1/tracks/2FgdtvJlotRv6uPHLV05B0",
      "id" : "2FgdtvJlotRv6uPHLV05B0",
      "name" : "Savannah",
      "preview_url" : "https://p.scdn.co/mp3-preview/be65af905468da00b01155c2cfc1d2ff348f0ff8?cid=null",
      "track_number" : 6,
      "type" : "track",
      "uri" : "spotify:track:2FgdtvJlotRv6uPHLV05B0"
    }, {
      "artists" : [ {
        "external_urls" : {
          "spotify" : "https://open.spotify.com/artist/1Uk4IDpF1OIuTzANugS5JC"
        },
        "href" : "https://api.spotify.com/v1/artists/1Uk4IDpF1OIuTzANugS5JC",
        "id" : "1Uk4IDpF1OIuTzANugS5JC",
        "name" : "Bass Modulators",
        "type" : "artist",
        "uri" : "spotify:artist:1Uk4IDpF1OIuTzANugS5JC"
      } ],
      "available_markets" : [ "AD", "AR", "AT", "AU", "BE", "BG", "BO", "BR", "CA", "CH", "CL", "CO", "CR", "CY", "CZ", "DE", "DK", "DO", "EC", "EE", "ES", "FI", "FR", "GB", "GR", "GT", "HK", "HN", "HU", "ID", "IE", "IS", "IT", "JP", "LI", "LT", "LU", "LV", "MC", "MT", "MX", "MY", "NI", "NL", "NO", "NZ", "PA", "PE", "PH", "PL", "PT", "PY", "SE", "SG", "SK", "SV", "TR", "TW", "US", "UY" ],
      "disc_number" : 1,
      "duration_ms" : 214393,
      "explicit" : false,
      "external_urls" : {
        "spotify" : "https://open.spotify.com/track/4C5uwjs9MXHBEqA3d70QGU"
      },
      "href" : "https://api.spotify.com/v1/tracks/4C5uwjs9MXHBEqA3d70QGU",
      "id" : "4C5uwjs9MXHBEqA3d70QGU",
      "name" : "Shadows",
      "preview_url" : "https://p.scdn.co/mp3-preview/168aef60804b5f11f05c6ff2b92d43023e970bdc?cid=null",
      "track_number" : 7,
      "type" : "track",
      "uri" : "spotify:track:4C5uwjs9MXHBEqA3d70QGU"
    }, {
      "artists" : [ {
        "external_urls" : {
          "spotify" : "https://open.spotify.com/artist/6qJ61DomA73g7jQEKESw9Z"
        },
        "href" : "https://api.spotify.com/v1/artists/6qJ61DomA73g7jQEKESw9Z",
        "id" : "6qJ61DomA73g7jQEKESw9Z",
        "name" : "Noisecontrollers",
        "type" : "artist",
        "uri" : "spotify:artist:6qJ61DomA73g7jQEKESw9Z"
      } ],
      "available_markets" : [ "AD", "AR", "AT", "AU", "BE", "BG", "BO", "BR", "CA", "CH", "CL", "CO", "CR", "CY", "CZ", "DE", "DK", "DO", "EC", "EE", "ES", "FI", "FR", "GB", "GR", "GT", "HK", "HN", "HU", "ID", "IE", "IS", "IT", "JP", "LI", "LT", "LU", "LV", "MC", "MT", "MX", "MY", "NI", "NL", "NO", "NZ", "PA", "PE", "PH", "PL", "PT", "PY", "SE", "SG", "SK", "SV", "TR", "TW", "US", "UY" ],
      "disc_number" : 1,
      "duration_ms" : 222400,
      "explicit" : false,
      "external_urls" : {
        "spotify" : "https://open.spotify.com/track/4Mb5KY93ldGRBMeuOyvwCb"
      },
      "href" : "https://api.spotify.com/v1/tracks/4Mb5KY93ldGRBMeuOyvwCb",
      "id" : "4Mb5KY93ldGRBMeuOyvwCb",
      "name" : "The Game",
      "preview_url" : "https://p.scdn.co/mp3-preview/147f695415d8ec79d3b824131d927329a47ee85e?cid=null",
      "track_number" : 8,
      "type" : "track",
      "uri" : "spotify:track:4Mb5KY93ldGRBMeuOyvwCb"
    }, {
      "artists" : [ {
        "external_urls" : {
          "spotify" : "https://open.spotify.com/artist/6qJ61DomA73g7jQEKESw9Z"
        },
        "href" : "https://api.spotify.com/v1/artists/6qJ61DomA73g7jQEKESw9Z",
        "id" : "6qJ61DomA73g7jQEKESw9Z",
        "name" : "Noisecontrollers",
        "type" : "artist",
        "uri" : "spotify:artist:6qJ61DomA73g7jQEKESw9Z"
      }, {
        "external_urls" : {
          "spotify" : "https://open.spotify.com/artist/1Uk4IDpF1OIuTzANugS5JC"
        },
        "href" : "https://api.spotify.com/v1/artists/1Uk4IDpF1OIuTzANugS5JC",
        "id" : "1Uk4IDpF1OIuTzANugS5JC",
        "name" : "Bass Modulators",
        "type" : "artist",
        "uri" : "spotify:artist:1Uk4IDpF1OIuTzANugS5JC"
      } ],
      "available_markets" : [ "AD", "AR", "AT", "AU", "BE", "BG", "BO", "BR", "CA", "CH", "CL", "CO", "CR", "CY", "CZ", "DE", "DK", "DO", "EC", "EE", "ES", "FI", "FR", "GB", "GR", "GT", "HK", "HN", "HU", "ID", "IE", "IS", "IT", "JP", "LI", "LT", "LU", "LV", "MC", "MT", "MX", "MY", "NI", "NL", "NO", "NZ", "PA", "PE", "PH", "PL", "PT", "PY", "SE", "SG", "SK", "SV", "TR", "TW", "US", "UY" ],
      "disc_number" : 1,
      "duration_ms" : 244609,
      "explicit" : false,
      "external_urls" : {
        "spotify" : "https://open.spotify.com/track/5g5HedGEcNp2IqMu8FFNcL"
      },
      "href" : "https://api.spotify.com/v1/tracks/5g5HedGEcNp2IqMu8FFNcL",
      "id" : "5g5HedGEcNp2IqMu8FFNcL",
      "name" : "Rocked Up - Live Edit",
      "preview_url" : "https://p.scdn.co/mp3-preview/c7177098e51677c3a08fe7f62d612a811025df84?cid=null",
      "track_number" : 9,
      "type" : "track",
      "uri" : "spotify:track:5g5HedGEcNp2IqMu8FFNcL"
    }, {
      "artists" : [ {
        "external_urls" : {
          "spotify" : "https://open.spotify.com/artist/6qJ61DomA73g7jQEKESw9Z"
        },
        "href" : "https://api.spotify.com/v1/artists/6qJ61DomA73g7jQEKESw9Z",
        "id" : "6qJ61DomA73g7jQEKESw9Z",
        "name" : "Noisecontrollers",
        "type" : "artist",
        "uri" : "spotify:artist:6qJ61DomA73g7jQEKESw9Z"
      }, {
        "external_urls" : {
          "spotify" : "https://open.spotify.com/artist/1Uk4IDpF1OIuTzANugS5JC"
        },
        "href" : "https://api.spotify.com/v1/artists/1Uk4IDpF1OIuTzANugS5JC",
        "id" : "1Uk4IDpF1OIuTzANugS5JC",
        "name" : "Bass Modulators",
        "type" : "artist",
        "uri" : "spotify:artist:1Uk4IDpF1OIuTzANugS5JC"
      } ],
      "available_markets" : [ "AD", "AR", "AT", "AU", "BE", "BG", "BO", "BR", "CA", "CH", "CL", "CO", "CR", "CY", "CZ", "DE", "DK", "DO", "EC", "EE", "ES", "FI", "FR", "GB", "GR", "GT", "HK", "HN", "HU", "ID", "IE", "IS", "IT", "JP", "LI", "LT", "LU", "LV", "MC", "MT", "MX", "MY", "NI", "NL", "NO", "NZ", "PA", "PE", "PH", "PL", "PT", "PY", "SE", "SG", "SK", "SV", "TR", "TW", "US", "UY" ],
      "disc_number" : 1,
      "duration_ms" : 155625,
      "explicit" : false,
      "external_urls" : {
        "spotify" : "https://open.spotify.com/track/7jbd4Pm2KB3v6IZYQPwYoL"
      },
      "href" : "https://api.spotify.com/v1/tracks/7jbd4Pm2KB3v6IZYQPwYoL",
      "id" : "7jbd4Pm2KB3v6IZYQPwYoL",
      "name" : "Break The Radiance",
      "preview_url" : "https://p.scdn.co/mp3-preview/97ffd77633d874e25b51b84dbd9fdeff495133c1?cid=null",
      "track_number" : 10,
      "type" : "track",
      "uri" : "spotify:track:7jbd4Pm2KB3v6IZYQPwYoL"
    } ],
    "limit" : 50,
    "next" : null,
    "offset" : 0,
    "previous" : null,
    "total" : 10
  },
  "type" : "album",
  "uri" : "spotify:album:4P5nTTfGxuCGZDHzT9DPAh"
}

Making a% of% of this will give you the exact image of the album:

$array = json_decode($html, true);

$imagem = $array['images']['0']['url'];

In this way you can include json_decode anywhere, because it is just any text:

echo '<img src="'.$imagem.'" />';

You will want to do this:

<img src="https://i.scdn.co/image/f7a13856ec2ce599e86c092d1caefc880fea5fbd"/>

Test this by clicking here.

    
24.01.2017 / 09:55