我想使用Google电子表格API阅读并撰写Google电子表格, 经过长时间的战斗,我能够获得访问令牌并将其存储在会话变量中,但我不明白如何交换此令牌以从电子表格中获取内容并更新电子表格。
我正在尝试使用以下代码来获取单元格内容。但没有任何回报。
<?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);
?>
答案 0 :(得分:0)
如果您没有“长期战斗”,请参阅http://framework.zend.com/manual/1.12/en/zend.gdata.html上的Google Spreadsheets
。您可以单独使用Zend Framework的组件(无需安装完整的ZF)。