Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Usar Google Spreadsheets como API
<?php
$id = '1ERm4xxxTNLeZOStU5vG4KdVIZMDp3rT_xxxfJsdck';
$url = 'https://spreadsheets.google.com/feeds/list/' . $id . '/od6/public/values?alt=json-in-script';
$json = file_get_contents($url);
$json = str_replace( array('gdata.io.handleScriptLoaded(',');'), '', $json);
$json = json_decode($json);
$items = array();
foreach( $json->feed->entry as $cols ){
$cols = (array)$cols;
$props = array();
foreach( $cols as $key => $col ){
if( strstr($key, 'gsx$') ){
$key = str_replace('gsx$', '', $key);
$val = $col->{'$t'};
$props[$key] = $val;
}
}
$items[] = $props;
}
echo json_encode( array('data' => $items) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.