20 Apr 2012 | Geonews: news from a location on a particular date

Geonews: news from a location on a particular date

This little function builds an array of news articles from the NYTimes back catalogue, related to a particular geographic location and around a particular date. Download it now.

The function uses the NYTimes Article Search API to pick up the articles and uses the geonames API to convert coordinates to a readable location.

The geonames lookup returns a hierarchy of locations, with the first being the most general (typically 'Earth') and the last being the most specific (typically a burrough, a suburb or a village).

The $window variable defines the number of days on each side of the date passed to the getNews function during which for the most specific location is to be searched for news. For one geographical level up, that window is halved, and so on, until the most general geographical is reached.
When the maximum number (or all) of requested news items has been fetched, the resulting collection of news is sorted on the distance in days from the date which was originally parsed.

Note that both APIs might enforce a limit on use.

This function is distributed as is, under a creative commons attribution 3.0 license.

Tagged with: API code geography location media news PHP


  • Me

After obtaining an M. Sc in maths, Babak Fakhamzadeh started with an office job at a major blue chip company but soon realised he'd do better on his own. Babak is a traveling web guru with a penchant for doing good and a love for visual and experimental art. Together with Eduardo Cachucho, he won the World Summit Award in the m-Tourism and Culture category in 2012 for Dérive app. With Ismail Farouk, he won the Highway Africa new media award in 2007 for Soweto Uprisings . com. Check out Babak's CV.


Babak is currently in Brasil.
+55 219 6557 5388 (Brasil)

February/March 2015