Thursday, July 7, 2011

The easiest way to parse Google Spreadsheets with PHP

After tinkering with the available publishing options for Google Docs Spreadsheets, I landed on the following.

$jsonData = file_get_contents("http://spreadsheets.google.com/feeds/list/YOUR-SPREADSHEET-ID/1/public/values?alt=json");
var_dump(json_decode($jsonData, true));

This makes the assumption that your spreadsheet content is not private and is OK to "publish as a web page".