Shoora
4/22/2015 - 8:47 PM

Get Google Spreadsheet Data

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>