【问题标题】:Permission denied for document creation using Gdata services使用 Gdata 服务创建文档的权限被拒绝
【发布时间】: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


    【解决方案1】:

    也许,您想尝试使用 API 上传一个空的电子表格,而不是执行 HTTP 请求。

    在此处查看更多详细信息:

    http://code.google.com/apis/documents/docs/1.0/developers_guide_php.html#UploadingSpreadsheet

    【讨论】:

    • 这就是Elizeu。正如我所说,我对此并不陌生,并且没有检查过这个“上传工具”。我已经让它工作了,然后我可以继续我的软件。我不会将此标记为正确答案,因为也许有人可以帮助实现上述代码。但我真的很感谢你的帮助。
    猜你喜欢
    • 2016-03-05
    • 2021-01-05
    • 1970-01-01
    • 2022-06-24
    • 2011-02-18
    • 1970-01-01
    • 2022-01-23
    • 2011-10-01
    • 2011-07-29
    相关资源
    最近更新 更多