I am looking to retrieve the XML of a Wikipedia page using their api. The URL I'm using is the following: http://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&format=xml&redirects&titles=dog
I've seen this, but it hasn't helped. No matter what I do, I'm not actually getting anything returned to $c, and I can't figure out why. I can do file_get_contents
with a plain text file, and it works just fine. Can anyone else verify that this works?
<?php
$url = 'http://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&format=xml&redirects&titles=Main%20Page';
$c = file_get_contents($url);
echo $c;
?>
EDIT I have also tried the cURL available on that page, which also doesn't work:
$url = 'http://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&format=xml&redirects&titles=Main%20Page';
$ch = curl_init($url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$c = curl_exec($ch);
echo $c;