使用curl和php检索googledocs演示文稿时出现问题

使用curl和php检索googledocs演示文稿时出现问题,curl,google-docs,google-docs-api,google-drive-api,Curl,Google Docs,Google Docs Api,Google Drive Api,当我试图通过php使用curl访问已发布的演示文稿时,就会出现问题。普通文档可以通过curl访问,但不能通过演示文稿访问。我想让这种检索文档的方法发挥作用,或者找到一种替代方法。谷歌的支持人员没有给我答案,建议堆栈溢出 起初,试图通过curl访问演示文稿时出现以下错误: Secure Connection Failed An error occurred during a connection to develop.willf-rtb-dev.switchsoft.com. SSL rece

当我试图通过php使用curl访问已发布的演示文稿时,就会出现问题。普通文档可以通过curl访问,但不能通过演示文稿访问。我想让这种检索文档的方法发挥作用,或者找到一种替代方法。谷歌的支持人员没有给我答案,建议堆栈溢出

起初,试图通过curl访问演示文稿时出现以下错误:

Secure Connection Failed

An error occurred during a connection to develop.willf-rtb-dev.switchsoft.com.

SSL received a record that exceeded the maximum permissible length.

(Error code: ssl_error_rx_record_too_long)
Sorry, the file you have requested does not exist.

Please check the address and try again.
我在我的开发框中为我的测试域添加了vhost以启用ssl。此vhost从以下行开始:

<VirtualHost *:443>
    SSLEngine on
    SSLCertificateFile    /etc/ssl/certs/ssl-cert-snakeoil.pem
    SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
我的php curl代码如下所示:

$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSLVERSION,3);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,3);

$cookieFile = TMP_DIRECTORY . '/curlcookies.txt';
if (!file_exists($cookieFile)) {
file_put_contents($cookieFile, '');
}
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFile);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieFile);

curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; Linux x86_64; rv:19.0) Gecko/20100101 Firefox/19.0 FirePHP/0.4");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);

$result = curl_exec($ch);
curl_close($ch);
return $result;
我尝试使用这种url样式下载演示文稿的html:

这要求我登录,当我登录时,会出现以下错误:

Secure Connection Failed

An error occurred during a connection to develop.willf-rtb-dev.switchsoft.com.

SSL received a record that exceeded the maximum permissible length.

(Error code: ssl_error_rx_record_too_long)
Sorry, the file you have requested does not exist.

Please check the address and try again.
当使用exportFormat=pdf时,我没有遇到这个错误——只要我登录,它就可以工作,但这不是我需要的

我还没有尝试使用它,但我在这里发现了一些php代码,这些代码可能值得研究:

任何人在这个问题上能给我任何提示或帮助都将不胜感激

致意


威尔·费勒(Will Ferrer)

我认为问题在于您试图将其导出为HTML的export语句

请注意,在google presentation frontend中,它只允许导出为pdf、pptx、txt、jpg、png和svg


在谷歌文档中,它还声明演示文稿的值仅为:“pdf”、“png”和“ppt”。

有什么想法吗?有人吗?谢谢,你好。非常感谢您的回复。在阅读我最初的帖子时,我认为我没有把这个问题完全弄清楚。目前,我并没有使用上面描述的方法,而是通过curl:联系发布的演示文稿的url,尝试访问发布的演示文稿。你上面描述的方法是我想用的一种方法。非常感谢您的帮助。我认为您试图访问的URL只能通过浏览器访问。为了下载演示文稿,您应该尝试通过curl访问。