Extracting data from Apple iTunes

E

I tried a lot to find RSS feeds for latest apps getting posted on Apple iTunes store under all categories but couldnt find anywhere, not sure why Apple does not provide such feed.

So I decided to write one of my own and below is how I accomplished the task using curl in php. Through httpfiddler I first out request headers sent by iTunes software and used the same.

 

<?php

function gunzip($zipped) {
$offset = 0;
if (substr($zipped,0,2) == "x1fx8b")
$offset = 2;
if (substr($zipped,$offset,1) == "x08")  {
# file_put_contents("tmp.gz", substr($zipped, $offset - 2));
return gzinflate(substr($zipped, $offset + 8));
}
return "Unknown Format";
}

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://itunes.apple.com/WebObjects/MZStore.woa/wa/browse?path=%2F36%2F6000%2F1');
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'X-Apple-Tz: 29600',
'X-Apple-Store-Front: 253477,27',
'Accept-Encoding: gzip',
'Accept-Language: en-us, en;q=0.50',
));

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
echo gunzip($output);

?>

 

 

 

About the author

Nishant Bamb
By Nishant Bamb

Category