Google Spreadsheet API with PHP

天涯浪子 提交于 2019-12-06 15:09:25

问题


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);
?>

回答1:


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).



来源:https://stackoverflow.com/questions/20851420/google-spreadsheet-api-with-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!