简体   繁体   中英

Google Spreadsheet API with PHP

I want to read from and write to Google spreadsheet using google spreadsheet API, After long battle I was able to get access token and stored it in a session variable, but i don't understand how to exchange this token to get contents from spreadsheet and to update spreadsheet.

I was trying with below code to get a cell content. But nothing is being returned.

<?php
session_start();
$url =  'https://spreadsheets.google.com/feeds/cells/0AgxnPrGJ8****************RkMwSkZoQ2pXaFE/4/private/full/R2C2';

$headers = array(
                'Authorization' => 'Bearer '.$_SESSION['access_token'],
                'Gdata-version' => '3.0'                                                                        
            );

$postdata = http_build_query($headers);
$context =
        array("http"=>
        array(
            "method" => "GET",
            "content" => $postdata
             )
             ); 
$context = stream_context_create($context);
$ResultArray = file_get_contents($url, false, $context);
var_dump($ResultArray);
?>

See Google Spreadsheets on http://framework.zend.com/manual/1.12/en/zend.gdata.html , if you wan`t have "long battles". Your can using components of Zend Framework separately (without install full ZF).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM