任何人知道如何以后的文件使用的卷曲的谷歌的文件。我写这些代码:

$header[] = "Authorization: GoogleLogin auth=seсretkey";
$header[] = "Content-Type: application/pdf";
$header[] = "Slug: testdoc";
$header[] = "Content-Length: ".$_FILES['file']['size']."";
$url = "http://docs.google.com/feeds/documents/private/full";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);            
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, file_get_contents($_FILES['file']['tmp_name']));
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
$response = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);    

和它工作正常,只有如果我使用的明文/文字内容类型的文本的文件,但如果我上传文件,在二元模式,我有417http错误,例如与pdf文件。

我已经尝试改变这条线

curl_setopt($ch, CURLOPT_POSTFIELDS, file_get_contents($_FILES['file']['tmp_name']));

到这个

curl_setopt($ch, CURLOPT_POSTFIELDS, array("file"=>"@".$_FILES['file']['tmp_name']));

但是我已经得到了417响应错误代码了。只有纯/文本应是201中。

例的文件上传头 官方来源

POST /feeds/documents/private/full HTTP/1.1
Host: docs.google.com
Authorization: <your authorization header here>
Content-Length: 81047
Content-Type: application/vnd.ms-excel
Slug: Example Spreadsheet

... spreadsheet contents here ...
有帮助吗?

解决方案

检查了 这篇文章.它提供了一个伟大的书面记录的关于如何使用的卷曲包括如何,以后变量。我不知道如何使用此与谷歌的文档,但是只要你下他们的指令,那么这应该帮你找出你的后var问题。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top