1

我正在使用 Zend GData 将文档上传到 Google 文档。

该代码工作正常,除了偶尔会引发异常:

400 Bad Request - Unable to convert document.

这是一个间歇性问题。所以我相信代码不是问题。

try {
    $test=$sharedocs->insertEntry($dataShare, $uri, 'Zend_Gdata_Entry',$header);
} catch (Exception $e ) {
    echo $e->getMessage();
    exit();
}

这是例外

    Zend_Gdata_App_HttpException 对象
    (
        [_httpClientException:protected] =>
        [_response:protected] => Zend_Http_Response 对象
            (
                [版本:受保护] => 1.1
                [代码:受保护] => 400
                [消息:受保护] => 错误请求
                [标题:受保护] => 数组
                    (
                        [内容类型] => 文本/html;字符集=UTF-8
                        [日期] => 格林威治标准时间 2012 年 12 月 14 日星期五 23:32:18
                        [过期] => 格林威治标准时间 2012 年 12 月 14 日星期五 23:32:18
                        [缓存控制] => 私有,max-age=0
                        [X-content-type-options] => nosniff
                        [X-frame-options] => SAMEORIGIN
                        [X-xss-保护] => 1; 模式=块
                        [服务器] => GSE
                        [连接] => 关闭
                    )
                [body:protected] => 无法转换文档。
            )
        [_previous:Zend_Exception:private] =>
        [message:protected] => 预期响应码 200,得到 400
    无法转换文档。
        [字符串:异常:私人] =>
        [代码:受保护] => 0
        [文件:受保护] => /usr/local/zend/share/ZendFramework/library/Zend/Gdata/App.php
        [行:受保护] => 714
        [trace:Exception:private] => 数组
            (
                [0] => 数组
                    (
                        [文件] => /usr/local/zend/share/ZendFramework/library/Zend/Gdata.php
                        [行] => 219
                        [功能] => 执行HttpRequest
                        [类] => Zend_Gdata_App
                        [类型] => ->
                        [参数] => 数组
                            (
                                [0] => 发布
                                [1] => https://docs.google.com/feeds/documents/private/full
                                [2] => 数组
                                    (
                                        [0] => 内容类型:多部分/相关;边界="END_OF_PART"
                                        [1] => 蛞蝓:test.doc
                                        [2] => 内容类型:应用程序/msword
                                        [3] => 资源 ID:4321
                                        [x-http-method-override] =>
                                        [授权] => AuthSub token="xxxxx"
                                    )
                                [3] =>
        
          
          辩论室 (12345)
        
                                [4] => 应用程序/原子+xml
                                [5] =>
                            )
                    )
                [1] => 数组
                    (
                        [文件] => /usr/local/zend/share/ZendFramework/library/Zend/Gdata/App.php
                        [行] => 905
                        [功能] => 执行HttpRequest
                        [类] => Zend_Gdata
                        [类型] => ->
                        [参数] => 数组
                            (
                                [0] => 发布
                                [1] => https://docs.google.com/feeds/documents/private/full
                                [2] => 数组
                                    (
                                        [0] => 内容类型:多部分/相关;边界="END_OF_PART"
                                        [1] => 蛞蝓:test.doc
                                        [2] => 内容类型:应用程序/msword
                                        [3] => 资源 ID:4321
                                        [x-http-method-override] =>
                                    )
                                [3] =>
        
          
          辩论室 (12345)
        
                                [4] => 应用程序/原子+xml
                            )
                    )
                [2] => 数组
                    (
                        [文件] => /usr/local/zend/share/ZendFramework/library/Zend/Gdata/App.php
                        [线] => 980
                        [功能] => 发布
                        [类] => Zend_Gdata_App
                        [类型] => ->
                        [参数] => 数组
                            (
                                [0] =>
        
          
          辩论室 (12345)
        
                                [1] =>
                                [2] =>
                                [3] =>
                                [4] => 数组
                                    (
                                        [0] => 内容类型:多部分/相关;边界="END_OF_PART"
                                        [1] => 蛞蝓:test.doc
                                        [2] => 内容类型:应用程序/msword
                                        [3] => 资源 ID:4321
                                    )
                            )
                    )
                [3] => 数组
                    (
                        [文件] => /var/www/GoogleFunctions.php
                        [线] => 90
                        [功能] => 插入条目
                        [类] => Zend_Gdata_App
                        [类型] => ->
                        [参数] => 数组
                            (
                                [0] =>
        
          
          辩论室 (12345)
        
                                [1] =>
                                [2] => Zend_Gdata_Entry
                                [3] => 数组
                                    (
                                        [0] => 内容类型:多部分/相关;边界="END_OF_PART"
                                        [1] => 蛞蝓:test.doc
                                        [2] => 内容类型:应用程序/msword
                                        [3] => 资源 ID:4321
                                    )
                            )
                    )
                [4] => 数组
                    (
                        [文件] => /var/www/myPaper.php
                        [行] => 342
                        [功能] => createNewDoc
                        [参数] => 数组
                            (
                                [0] => 辩论空间 (12345)
                                [1] => Zend_Gdata_Docs 对象
                                    (
                                        [_defaultPostUri:protected] => https://docs.google.com/feeds/documents/private/full
                                        [_registeredPackages:protected] => 数组
                                            (
                                                [0] => Zend_Gdata_Docs
                                                [1] => Zend_Gdata_Kind
                                                [2] => Zend_Gdata_Extension
                                                [3] => Zend_Gdata
                                                [4] => Zend_Gdata_App_Extension
                                                [5] => Zend_Gdata_App
                                            )
                                        [_httpClient:protected] => Zend_Gdata_HttpClient 对象
                                            (
                                                [_authSubPrivateKeyId:Zend_Gdata_HttpClient:private] =>
                                                [_authSubToken:Zend_Gdata_HttpClient:private] => 1/xxxxx
                                                [_clientLoginToken:Zend_Gdata_HttpClient:private] =>
                                                [_clientLoginKey:Zend_Gdata_HttpClient:private] =>
                                                [_streamingRequest:protected] =>
                                                [配置:受保护] => 数组
                                                    (
                                                        [最大重定向] => 0
                                                        [严格重定向] => 1
                                                        [用户代理] => Zend_Framework_Gdata/1.11.12
                                                        [超时] => 10
                                                        [适配器] => Zend_Http_Client_Adapter_Socket
                                                        [http版本] => 1.1
                                                        [保活] =>
                                                        [商店响应] => 1
                                                        [严格] => 1
                                                        [输出流] =>
                                                        [编码饼干] => 1
                                                        [rfc3986_strict] =>
                                                    )
                                                [适配器:受保护] => Zend_Http_Client_Adapter_Socket 对象
                                                    (
                                                        [套接字:受保护] =>
                                                        [connected_to:protected] => 数组
                                                            (
                                                                [0] =>
                                                                [1] =>
                                                            )
                                                        [out_stream:protected] =>
                                                        [配置:受保护] => 数组
                                                            (
                                                                [持久] =>
                                                                [ssltransport] => ssl
                                                                [sslcert] =>
                                                                [sslpassphrase] =>
                                                                [ssluse上下文] =>
                                                                [最大重定向] => 0
                                                                [严格重定向] => 1
                                                                [用户代理] => Zend_Framework_Gdata/1.11.12
                                                                [超时] => 10
                                                                [http版本] => 1.1
                                                                [保活] =>
                                                                [商店响应] => 1
                                                                [严格] => 1
                                                                [输出流] =>
                                                                [编码饼干] => 1
                                                                [rfc3986_strict] =>
                                                            )

                                                        [方法:受保护] => POST
                                                        [_context:protected] => 资源 ID #10
                                                    )
                                                [uri:protected] => Zend_Uri_Http 对象
                                                    (
                                                        [_username:protected] =>
                                                        [_密码:受保护] =>
                                                        [_host:protected] => docs.google.com
                                                        [_port:protected] => 443
                                                        [_path:protected] => /feeds/documents/private/full
                                                        [_query:protected] =>
                                                        [_fragment:protected] =>
                                                        [_regex:protected] => 数组
                                                            (
                                                                [转义] => %[[:xdigit:]]{2}
                                                                [未保留] => [A-Za-z0-9-_.!~*'()\[\]]
                                                                [段] => (?:%[[:xdigit:]]{2}|[A-Za-z0-9-_.!~*'()\[\]:@&=+$,;] )*
                                                                [路径] => (?:\/(?:(?:%[[:xdigit:]]{2}|[A-Za-z0-9-_.!~*'()\[\]: @&=+$,;])*)?)+
                                                                [尿酸] => (?:%[[:xdigit:]]{2}|[A-Za-z0-9-_.!~*'()\[\];\/?:@&=+ $,])
                                                            )

                                                        [_scheme:protected] => https
                                                    )
                                                [标题:受保护] => 数组
                                                    (
                                                        [用户代理] => 数组
                                                            (
                                                                [0] => 用户代理
                                                                [1] => MyCompany-MyApp-1.0 Zend_Framework_Gdata/1.11.12
                                                            )
                                                        [内容类型] => 数组
                                                            (
                                                                [0] => 内容类型
                                                                [1] => 应用程序/原子+xml
                                                            )
                                                        [蛞蝓] => 数组
                                                            (
                                                                [0] => 蛞蝓
                                                                [1] => 测试.doc
                                                            )
                                                        [resourceid] => 数组
                                                            (
                                                                [0] => 资源 ID
                                                                [1] => 4321
                                                            )
                                                        [授权] => 数组
                                                            (
                                                                [0] => 授权
                                                                [1] => AuthSub 令牌="1/xxxxx"
                                                            )
                                                        [接受编码] => 数组
                                                            (
                                                                [0] => 接受编码
                                                                [1] => 身份
                                                            )
                                                        [内容长度] => 数组
                                                            (
                                                                [0] => 内容长度
                                                                [1] => 273
                                                            )
                                                    )
                                                [方法:受保护] => POST
                                                [paramsGet:protected] => 数组
                                                    (
                                                    )
                                                [paramsPost:protected] => 数组
                                                    (
                                                    )
                                                [enctype:protected] => 应用程序/原子+xml
                                                [raw_post_data:protected] =>
        
          
          辩论室 (12345)
        
                                                [认证:受保护] =>
                                                [文件:受保护] => 数组
                                                    (
                                                    )
                                                [body_field_order:protected] => 数组
                                                    (
                                                        [服务] => 标量
                                                    )
                                                [cookiejar:受保护] =>
                                                [last_request:protected] => POST /feeds/documents/private/full HTTP/1.1
    主机:docs.google.com
    连接:关闭
    用户代理:MyCompany-MyApp-1.0 Zend_Framework_Gdata/1.11.12
    内容类型:application/atom+xml
    蛞蝓:test.doc
    资源 ID:4321
    授权:AuthSub token="1/xxxxx"
    接受编码:身份
    内容长度:273

    
        
          
          辩论室 (12345)
        
                                                [last_response:protected] => Zend_Http_Response 对象
                                                    (
                                                        [版本:受保护] => 1.1
                                                        [代码:受保护] => 400
                                                        [消息:受保护] => 错误请求
                                                        [标题:受保护] => 数组
                                                            (
                                                                [内容类型] => 文本/html;字符集=UTF-8
                                                                [日期] => 格林威治标准时间 2012 年 12 月 14 日星期五 23:32:18
                                                                [过期] => 格林威治标准时间 2012 年 12 月 14 日星期五 23:32:18
                                                                [缓存控制] => 私有,max-age=0
                                                                [X-content-type-options] => nosniff
                                                                [X-frame-options] => SAMEORIGIN
                                                                [X-xss-保护] => 1; 模式=块
                                                                [服务器] => GSE
                                                                [连接] => 关闭
                                                            )
                                                        [body:protected] => 无法转换文档。
                                                    )
                                                [redirectCounter:protected] => 0
                                                [_unmaskStatus:protected] =>
                                                [_queryBracketsEscaped:protected] => 1
                                            )
                                        [_majorProtocolVersion:protected] => 1
                                        [_minorProtocolVersion:protected] =>
                                        [_useObjectMapping:protected] => 1
                                    )
                            )
                    )
            )
        [上一个:例外:私人] =>
    )

4

1 回答 1

0

哦,所以我在同一行回答了某人的问题,却忘了把它放在我的问题上。:D

( https://stackoverflow.com/a/14290948/1736522 ) Google Docs/Drive API 不允许将新文档插入新的 Google 帐户

于 2013-07-27T19:20:28.307 回答