Last active
July 25, 2016 16:50
-
-
Save philipp-r/cda11cfd9cfcaad9111e to your computer and use it in GitHub Desktop.
iTunes Search API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Wonach wird gesucht? | |
$searchQuery = "284910350"; | |
// iTunes API Request | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, "https://itunes.apple.com/de/lookup?id=".$searchQuery); | |
curl_setopt($ch, CURLOPT_HEADER, 0); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
$apiRequest = curl_exec($ch); | |
curl_close($ch); | |
// PHP Array erstellen | |
$apiResult = json_decode($apiRequest, true); | |
// erstes Ergebnis | |
$firstResult = $apiResult['results'][0]; | |
/* | |
Informationen aus der API: | |
KEY: DESCRIPTION: VALUES: | |
"wrapperType" kind of the result "software" for app; "track" for song or movie; "collection" for album or tv show | |
[if "wrapperType" = "software"] | |
{ | |
"kind" app kind "software" for iOS; "mac-software" for Mac | |
[if "kind" = "software"] | |
{ | |
"supportedDevices" supported iOS devices Array with Strings | |
} | |
"trackName" app name String | |
"trackViewUrl" iTunes URL without affiliate code URL | |
"price" Price Integer | |
"formattedPrice" Price with currency symbol String | |
"genres" genres Array with Strings | |
"screenshotUrls" iPhone or Mac screenshots Array with URLs | |
"ipadScreenshotUrls" iPad screenshots Array with URLs | |
} | |
[if "wrapperType" = "track"] | |
{ | |
"kind" track kind "song" for music Song; "feature-movie" for movie | |
"trackName" name String | |
"trackPrice" Price Integer | |
"trackViewUrl" iTunes URL without affiliate code URL | |
"previewUrl" Link to preview media file URL | |
} | |
[if "wrapperType" = "collection"] | |
{ | |
"collectionType" kind "Album" for album; "TV Season" for TV show | |
"collectionName" name String value | |
"collectionViewUrl" iTunes URL without affiliate code URL | |
"collectionPrice" Price without currency Integer | |
} | |
"primaryGenreName" genre String value | |
"artistName" name of publisher/creator String value | |
"artworkUrl60" URL to .jpg icon smaller URL | |
"artworkUrl100" URL to .jpg icon bigger URL | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment