大家好我想使用以下代码在谷歌应用程序帐户上传谷歌文档 - 我正在使用zend框架:
function getGoogleClient($s = '')
{
$service = Zend_Gdata_Docs::AUTH_SERVICE_NAME;
$user = 'aaaaa';
$pass = 'aaaaa';
$httpClient = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
return $httpClient;
}
function uploadDocument($docs, $html, $originalFileName, $temporaryFileLocation) {
$fileToUpload = $originalFileName;
if ($temporaryFileLocation) {
$fileToUpload = $temporaryFileLocation;
}
$newDocumentEntry = $docs->uploadFile($fileToUpload, $originalFileName, null, Zend_Gdata_Docs::DOCUMENTS_LIST_FEED_URI);
}
$client = getGoogleClient();
$docs = new Zend_Gdata_Docs($client);
$ls = uploadDocument($docs, true, $file->filename, $file->tmp_name);
BUt我一直收到这个错误 - 这里有什么错误:(
Expected response code 200, got 400 Inconsistent repeating query parameter
答案 0 :(得分:1)
Zend_Gdata_Docs中有一个带有mimetype的“bug”。 如果您使用临时文件并且文件名为标题,则不会自动为您拉出mimetype。它尝试根据临时文件中不存在的fileLocation扩展名来拉取mimetype。
我创建了一个适合我的课程,而不是更新Zend课程。 它被称为ConvertDoc,因为我希望能够upload a spreadsheet and download as csv.
你真正需要的是......
// get mimetype from original file name
$filenameParts = explode('.', $originalFileName);
$fileExtension = end($filenameParts);
$mimeType = Zend_Gdata_Docs::lookupMimeType($fileExtension);
传递$ mimetype而不是null。