Usar Google Spreadsheets como API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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