Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.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
Php 从CURL请求中获取特定内容_Php_Curl - Fatal编程技术网

Php 从CURL请求中获取特定内容

Php 从CURL请求中获取特定内容,php,curl,Php,Curl,我试图从Spotify URI中获取歌曲标题和艺术家 当前->获取用户ID和播放列表ID->创建嵌入式播放列表->吐出整个播放列表 我真正想做的就是用纯文本打印歌曲列表。我希望尽可能避免使用SpotifyAPI --index.php <html> <link rel="stylesheet" href="_/css/style.css" /> <script src="_/js/inputcheck.js"></script> <bod

我试图从Spotify URI中获取歌曲标题和艺术家

当前->获取用户ID和播放列表ID->创建嵌入式播放列表->吐出整个播放列表

我真正想做的就是用纯文本打印歌曲列表。我希望尽可能避免使用SpotifyAPI

--index.php

<html>

<link rel="stylesheet" href="_/css/style.css" />
<script src="_/js/inputcheck.js"></script>
<body>

<section id="outPopUp">
    <form name="myForm" class="input-list style-1 clearfix" action="get_playlist.php" onsubmit="return validateForm()" method="get">
    Spotify URI to MP3:
    <input type="text" name="uri"><br>
    <input class="myButton" type="submit">

</section>
</body>
</html>

Spotify URI到MP3:

--get_playlist.php

<?php

$uri = $_GET['uri'];

// Match exact Spotify playlist URI pattern
if ($c=preg_match_all("/".'(spotify)'.'(:)'.'(user)'.'(:)'.'((?:[A-Za-z0-9_-]*))'.'(:)'.'(playlist)'.'(:)'.'((?:[A-Za-z0-9]*))'."/is", $uri, $matches)) {
    $userID = $matches[5][0];
    $playlistID = $matches[9][0];
} else {
echo 'Error: Could not parse URI. Script needs ?uri= with the Spotify playlist URI.';
die;
}

$url = "https://embed.spotify.com/?uri=spotify:user:".$userID.":playlist:".$playlistID."&output=json";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; curl)");
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$embeddedplayer = curl_exec($ch);
curl_close($ch);

echo $embeddedplayer;

?>


如果有人能帮上忙,那就太好了

为什么不使用Spotify API?NODE.js整天都在困扰着我。为什么不使用Jigar在这里发布的PHP库呢?他们有一个API-使用它