Hmm, this isn't very easy. You're not getting anything back from Commons:Potd
because that's just a redirect, but even if you fetch images from Commons:Picture of the Day
, you just get a huge list of all images ever in alphabetical order.
But here's one solution. First expand the Potd template to figure out the current image name:
http://commons.wikimedia.org/w/api.php?action=expandtemplates&text={{Potd/{{CURRENTYEAR}}-{{CURRENTMONTH}}-{{CURRENTDAY2}}}}
<api>
<expandtemplates xml:space="preserve">20110421 Tbilisi Georgia Panoramic.jpg</expandtemplates>
</api>
Then plug that filename (URL-encoded) into a separate request to imageinfo, with iiprop=url
to get the URL:
http://commons.wikimedia.org/w/api.php?titles=Image:20110421%20Tbilisi%20Georgia%20Panoramic.jpg&action=query&prop=imageinfo&iiprop=url
And there it is!
The picture file itself can be retrieved using the value of the url
attribute:
<api>
<query>
<normalized>
<n from="Image:20110421 Tbilisi Georgia Panoramic.jpg" to="File:20110421 Tbilisi Georgia Panoramic.jpg" />
</normalized>
<pages>
<page pageid="15527584" ns="6" title="File:20110421 Tbilisi Georgia Panoramic.jpg" imagerepository="local">
<imageinfo>
<ii url="http://upload.wikimedia.org/wikipedia/commons/a/ae/20110421_Tbilisi_Georgia_Panoramic.jpg" descriptionurl="http://commons.wikimedia.org/wiki/File:20110421_Tbilisi_Georgia_Panoramic.jpg" />
</imageinfo>
</page>
</pages>
</query>
</api>