【问题标题】:Extract Preview_Url through spotify API通过 spotify API 提取 Preview_Url
【发布时间】:2017-04-23 04:03:33
【问题描述】:

好吧,我打算通过 Spotify API 提取函数 preview_url,但我无法在代码后面找到这个函数,所以我来寻求您的帮助。

"preview_url" : "https://p.scdn.co/mp3-preview/5dcd99cf811094408dcfc1befe014495d786dab5",

{
  "artists" : {
    "href" : "https://api.spotify.com/v1/search?query=MAROON+5+ANIMALS&offset=0&limit=1&type=artist",
    "items" : [ ],
    "limit" : 1,
    "next" : null,
    "offset" : 0,
    "previous" : null,
    "total" : 0
  },
  "tracks" : {
    "href" : "https://api.spotify.com/v1/search?query=MAROON+5+-+ANIMALS&offset=0&limit=1&type=track",
    "items" : [ {
      "album" : {
        "album_type" : "album",
        "artists" : [ {
          "external_urls" : {
            "spotify" : "https://open.spotify.com/artist/04gDigrS5kc9YWfZHwBETP"
          },
          "href" : "https://api.spotify.com/v1/artists/04gDigrS5kc9YWfZHwBETP",
          "id" : "04gDigrS5kc9YWfZHwBETP",
          "name" : "Maroon 5",
          "type" : "artist",
          "uri" : "spotify:artist:04gDigrS5kc9YWfZHwBETP"
        } ],
        "available_markets" : [ "CA", "MX", "US" ],
        "external_urls" : {
          "spotify" : "https://open.spotify.com/album/2Auw0pTT6EcQdvHNimhLQI"
        },
        "href" : "https://api.spotify.com/v1/albums/2Auw0pTT6EcQdvHNimhLQI",
        "id" : "2Auw0pTT6EcQdvHNimhLQI",
        "images" : [ {
          "height" : 640,
          "url" : "https://i.scdn.co/image/4c23a82f33b034795a0fbc67af559420c8cb4928",
          "width" : 640
        }, {
          "height" : 300,
          "url" : "https://i.scdn.co/image/44b0e6423240ed25f36f351ae043f68bb2ca3446",
          "width" : 300
        }, {
          "height" : 64,
          "url" : "https://i.scdn.co/image/2e8ff05c6f96006130bbc64ef0b42b402252ace8",
          "width" : 64
        } ],
        "name" : "V",
        "type" : "album",
        "uri" : "spotify:album:2Auw0pTT6EcQdvHNimhLQI"
      },
      "artists" : [ {
        "external_urls" : {
          "spotify" : "https://open.spotify.com/artist/04gDigrS5kc9YWfZHwBETP"
        },
        "href" : "https://api.spotify.com/v1/artists/04gDigrS5kc9YWfZHwBETP",
        "id" : "04gDigrS5kc9YWfZHwBETP",
        "name" : "Maroon 5",
        "type" : "artist",
        "uri" : "spotify:artist:04gDigrS5kc9YWfZHwBETP"
      } ],
      "available_markets" : [ "CA", "MX", "US" ],
      "disc_number" : 1,
      "duration_ms" : 231012,
      "explicit" : false,
      "external_ids" : {
        "isrc" : "USUM71409576"
      },
      "external_urls" : {
        "spotify" : "https://open.spotify.com/track/2bL2gyO6kBdLkNSkxXNh6x"
      },
      "href" : "https://api.spotify.com/v1/tracks/2bL2gyO6kBdLkNSkxXNh6x",
      "id" : "2bL2gyO6kBdLkNSkxXNh6x",
      "name" : "Animals",
      "popularity" : 69,
      "preview_url" : "https://p.scdn.co/mp3-preview/5dcd99cf811094408dcfc1befe014495d786dab5",
      "track_number" : 2,
      "type" : "track",
      "uri" : "spotify:track:2bL2gyO6kBdLkNSkxXNh6x"
    } ],
    "limit" : 1,
    "next" : "https://api.spotify.com/v1/search?query=MAROON+5+-+ANIMALS&offset=1&limit=1&type=track",
    "offset" : 0,
    "previous" : null,
    "total" : 99
  }
}

让我达到所需功能的代码

$get_json->tracks->items[0]->artists[1]->external_urls->preview_url;

你能帮帮我吗?谢谢!

【问题讨论】:

  • 在发布问题之前您做了哪些研究?有什么发现吗?
  • @OleV.V.我一直在搜索这个网站,我注意到这个答案问题 (stackoverflow.com/questions/39913982/…) 并试图适应我的问题但没有成功或删除指定函数的 preview_url

标签: javascript java php echo spotify


【解决方案1】:

您似乎没有找到preview_url 值的正确路径。实际路径是tracks->items[0]->preview_url。希望这在某种程度上有所帮助。

【讨论】:

  • @Michaek Thelin 感谢 Michael 为解决这个问题所给予的宝贵帮助,这正是我想要的。谢谢!
  • 没有问题 - 很高兴它解锁了你!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-06-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-10-11
  • 2021-02-11
  • 2013-09-21
相关资源
最近更新 更多