【发布时间】:2011-09-01 23:21:18
【问题描述】:
我正在尝试使用 Gdata API 创建一个空的电子表格。 由于我在这里遇到了与其他朋友相同的问题(http://goo.gl/AHT7S),默认的 Zend API 不支持此操作。所以,我正在尝试实现它。
其实我差点就知道了,但我从 google 服务中得到了这个答案:403 - <errors xmlns='http://schemas.google.com/g/2005'><error><domain>GData</domain><code>ServiceForbiddenException</code><internalReason>You do not have permission to perform this operation.</internalReason></error></errors>
我正在使用最简单的方法:客户端登录 + Zend_GData 函数。我的代码是这样的(请原谅任何愚蠢的事情......我是 PHP 和 GData 的新手):
public function newSpreadsheet($name){
$line = "\n";
$tab = "\t";
$token = 'GoogleLogin auth=' . $this->login->getLoginToken();
$headers = array();
$headers['GData-Version'] = "3.0";
$headers['Authorization'] = $token;
$headers['Content-Length'] = '287';
$headers['Content-Type'] = 'application/atom+xml';
$url = 'https://docs.google.com/feeds/default/private/full';
$body = "<?xml version='1.0' encoding='UTF-8'?>".$line;
$body .= "<entry xmlns='http://www.w3.org/2005/Atom'>".$line;
$body .= $tab. "<category scheme='http://schemas.google.com/g/2005#kind'".$line;
$body .= $tab.$tab."term='http://schemas.google.com/docs/2007#document'/>".$line;
$body .= $tab."<title>".$name."</title>".$line;
$body .= "</entry>";
echo $body;
return parent::performHttpRequest('POST',$url,$headers,$body);
}
是否知道为什么我“无权”执行该操作?
【问题讨论】:
标签: gdata zend-gdata