$string=file_get_contents('http://itunes.apple.com/search?term=Avatar+Cameron&entity=iPadSoftware&country=DE&limit=1');
$json_o=json_decode($string);
$json_a=json_decode($string,true);
// associative array mode
echo $json_a[artworkUrl60];This question has been answered by BobRay. See the first response.
URL file-access is disabled in the server configuration
$ch = curl_init('http://itunes.apple.com/search?term=Avatar+Cameron&entity=iPadSoftware&country=DE&limit=1');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_NOSIGNAL, 1);
curl_setopt($ch, CURLOPT_TIMEOUT_MS, 200);
$string = curl_exec($ch);
$curl_errno = curl_errno($ch);
$curl_error = curl_error($ch);
curl_close($ch);
if ($curl_errno > 0) {
echo "cURL Error ($curl_errno): $curl_error\n";
} else {
echo "Data received: $data\n";
/* decode JSON here */
}
<?php
$ch = curl_init('http://itunes.apple.com/search?term=Avatar+Cameron&entity=iPadSoftware&country=DE&limit=5');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_NOSIGNAL, 1);
curl_setopt($ch, CURLOPT_TIMEOUT_MS, 200);
$string = curl_exec($ch);
$curl_errno = curl_errno($ch);
$curl_error = curl_error($ch);
curl_close($ch);
$arr = json_decode($string,true);
foreach($arr['results'] as $val)
{
echo "some html...";
echo $val['trackViewUrl'];
echo "more html...";
echo $val['artworkUrl60'];
echo "and more html...";
}