Thursday, 9 August 2018

PHP: ITunes API Example

This is a basic tutorial on how to search the iTunes API web service with PHP. This is particularly handy if you are looking for album artwork, artist singles or DVD covers.
Here is a simple example:
As you can see, we created a custom function called “search”, which constructs an API call to the iTunes web service (we encode our search term by using the function url_encode). We then decode the result from the API into an associative array using the json_decode function.
Later on, we loop through the search results before printing out the album artwork (if it exists – in some cases, it won’t).

0 comments:

Post a Comment