Skip to content

Instantly share code, notes, and snippets.

@rilinweb
Created April 22, 2015 20:47
Show Gist options
  • Save rilinweb/38e0fabde146e5d44f9a to your computer and use it in GitHub Desktop.
Save rilinweb/38e0fabde146e5d44f9a to your computer and use it in GitHub Desktop.
Get Google Spreadsheet Data
<?php
$spreadsheetID = '1pO7BBOkhWL2TcBPYkDTlWZ0Gbw4mAUSadK_8NOn0Ij8';
$urlPath = 'http://spreadsheets.google.com/feeds/list/' . $spreadsheetID . '/od6/public/values?alt=json';
$file = file_get_contents($urlPath);
$json = json_decode($file);
$rows = $json->{'feed'}->{'entry'};
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Get Google Spreadsheet Data</title>
<link rel="stylesheet" href="http://yandex.st/bootstrap/3.3.0/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<div class="page-header">
<h1>Get Google Spreadsheet Data Example</h1>
<p>See article <a target="_blank" href="http://rilin.ru/poluchaem-dann…le-i-vyvodim-i/">here</a></p>
</div>
<?php foreach ($rows as $row): ?>
<div class="jumbotron">
<h1>
<?php echo $row->{'gsx$title'}->{'$t'}; ?>
</h1>
<h2>
<?php echo $row->{'gsx$subtitle'}->{'$t'}; ?>
</h2>
<?php echo $row->{'gsx$description'}->{'$t'}; ?>
</div>
<?php endforeach; ?>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment