I'm trying to make a parser for a Kijiji RSS feed. The issue I'm having is that for some reason their RSS URL returns no results in a browser or in my script using CURL. However, if I parse the URL with a proper RSS Reader it works perfectly.
Here is an example URL https://www.kijiji.ca/rss-poa/u1001906046
It should return the following returns as an RSS feed https://www.kijiji.ca/o-tork-parts/1001906046
. The problem is that when I load the RSS URL in a browser it returns no ad listings. When I load the RSS URL at https://codebeautify.org/rssviewer
I see all the results.
My initial thought that I must pass the proper Accept
and User-Agent
headers. I created my own RSS page to sniff out what headers Code Beautify
passes. I got Accept: */*
and a blank user agent. I used that with my code, but still getting the same page with no listings.
My code looks like this
$url = "https://www.kijiji.ca/rss-poa/u1001906046";
$headers = array(
'Accept: */*',
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_USERAGENT,'');
$result = curl_exec($ch);
curl_close($ch);
echo $result;
What am I doing wrong?