我想使用Google spreadsheet API读取和写入google spreadsheet,经过长时间的斗争,我能够获得访问令牌并将其存储在会话变量中,但我不知道如何交换这个令牌来从电子表格中获取内容和更新电子表格。
我试着用下面的代码来获取单元格的内容。但是没有任何东西被退还。
<?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);
?>发布于 2013-12-31 12:00:47
如果你不想经历“漫长的战斗”,可以在http://framework.zend.com/manual/1.12/en/zend.gdata.html上看看Google Spreadsheets。您可以单独使用Zend Framework的组件(无需安装完整的ZF)。
https://stackoverflow.com/questions/20851420
复制相似问题