I'm currently trying to fetch the top 10 songs from itunes api, but it's giving me the following error :
DOMDocument::load(http://ax.itunes.apple.com/WebObjects/MZStore.woa/wpa/MRSS/topsongs/limit=10/rss.xml) [domdocument.load]: failed to open stream: Redirection limit reached, aborting
now this is the basic code for the fetching
$doc = new DOMDocument();
$doc->load('http://ax.itunes.apple.com/WebObjects/MZStore.woa/wpa/MRSS/topsongs/limit=10/rss.xml');
$arrFeeds = array();
foreach ($doc->getElementsByTagName('item') as $node) {
$itemRSS = array('title' => $node->getElementsByTagName('title')->item(0)->nodeValue);
array_push($arrFeeds, $itemRSS);
}
if anyone could help that would be great :D
Thanks
edit: also it seems to work sometimes, and then randomly stop other times.
It seems to be a very common problem - a search on that error string turns up tens of thousands of websites all spitting out exactly the same error so I would suspect it's on iTunes' end, not yours.
With this in mind, you might want to think about putting a check in to determine whether the XML has loaded successfully or not, and if it hasn't, displaying a cached version of the last successful pull from the iTunes server. It's not exactly a fix per se, more a coping method in dealing with what looks like a 3rd party error.