Spotify metadata api lookup form
trying to play around with the spotify metadata API to learn some JavaScript, jQuery and communicate with apis. What I'm trying to do is create a search function where you can type in the uri and it will return metadata information for an album. I basically want a response like this. The service base URL is "http://ws.spotify.com/lookup/1/". I want my result to be base URL + spotify URI + &extras=trackdetail. Example: http://ws.spotify.com/lookup/1/.json?uri=spotify:album:6G9fHYDCoyEErUkHrFYfs4&extras=trackdetail
I've tried to code this, but it doesn't seem to give anything in response. Any idea what I'm missing?
<p>
<form>
<div>
<label for="spotify-uri">Spotify URI:</label>
<input type="text" id="spotify-uri" name="spotify" required />
</div>
<div>
<input type="submit" id="btn-lookup" value="Look up spotify URI" />
</div>
</form>
</p>
<div id="URI-lookup-results">
<p>Here are the results:</p>
</div>
<script src="http://code.jquery.com/jquery-1.10.2.min.js">
</script>
<script>
$(document).ready(function () {
var $results = $('#URI-lookup-results'),
$uricode = $('#spotify-uri').val(),
extra = ("&extras=trackdetail");
var requestURL = 'http://ws.spotify.com/lookup/1/.json?' + extra';
$.ajax(requestURL, {
dataType: 'JSON'
uri: 'uricode'
})
.done(function (data) {
$.appendTo( #"URI-lookup-results" );
})
.fail(function (data) {
console.log(data);
})
});
</script>
链接地址: http://www.djcxy.com/p/55572.html
上一篇: 使用PHP获取和解析Spotify Web API JSON
下一篇: Spotify元数据api查找表单