Parse public google spreadsheet in PHP without any library

Go to your Spreadsheet in Google Drive.
Go to files -> Publish on the Web
Select the right worksheet and make sure to enable the checkbox always update.
Still in the same box you can get a .csv Link to your spreadsheet.

$spreadsheet_url= »https://docs.google.com/spreadsheet/pub?key=&single=true&gid=0&output=csv »;

if(!ini_set(‘default_socket_timeout’, 15)) echo « « ;

if (($handle = fopen($spreadsheet_url, « r »)) !== FALSE) {
while (($data = fgetcsv($handle, 1000, « , »)) !== FALSE) {
$spreadsheet_data[] = $data;
}
fclose($handle);
}
else
die(« Problem reading csv »);

Laisser un commentaire

décembre 6, 2017

Posted In: Code

Leave a Comment