Geonews: news from a location on a particular date Own stuff

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.

Share now

Contact Babak