我不知道前面的兩個帖子:谷歌驅動器SDK:插入無題文件導致PHP
- PHP Google Drive API - File Upload Only As "Untitled"-File Or Just Without Content
- Google Drive PHP SDK saves an Untitled file
但除了回答「你確定你正在使用最新的版本「,沒有一個提問者回來說如果是或否,或者他們是否設法找到答案。
因爲我在做同樣的事情,他們我使用的是最新的apiDriveService.php從2012年6月
日的最後一次修改的數據被正確地找到,但是當你在到達插入行,顯然會發生錯誤。
而我不明白爲什麼對於SDK的PHP例子,它似乎正確。
這是Google Api Console中的問題嗎?或者我需要將數據編碼爲特殊的東西?
編輯:在apiDriveService文件,我可以看到這一行:
$this->files = new FilesServiceResource($this, $this->serviceName, 'files', json_decode('{"methods": {
"insert": {"scopes": ["https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/drive.file"],
"parameters": {"convert": {"default": "false", "type": "boolean", "location": "query"}, "targetLanguage": {"type": "string", "location": "query"}, "sourceLanguage": {"type": "string", "location": "query"}, "ocrLanguage": {"type": "string", "location": "query"}, "pinned": {"default": "false", "type": "boolean", "location": "query"}, "ocr": {"default": "false", "type": "boolean", "location": "query"}, "timedTextTrackName": {"type": "string", "location": "query"}, "timedTextLanguage": {"type": "string", "location": "query"}}, "supportsMediaUpload": true, "request": {"$ref": "File"}, "mediaUpload": {"maxSize": "10GB", "accept": ["*/*"], "protocols": {"simple": {"path": "/upload/drive/v2/files", "multipart": true}, "resumable": {"path": "/resumable/upload/drive/v2/files", "multipart": true}}}, "id": "drive.files.insert", "httpMethod": "POST", "path": "files", "response": {"$ref": "File"}}, ...);
在我送參數,有數據和MIME類型:
$created = $apiService->files->insert($driveFile, array('data' => $data,'mimeType' => $mimeType));
而在插入功能,有一個array_merge與數據和mimetype:
public function insert(DriveFile $postBody, $optParams = array()) {
$params = array('postBody' => $postBody);
$params = array_merge($params, $optParams);
$data = $this->__call('insert', array($params));
if ($this->useObjects()) {
return new DriveFile($data);
} else {
return $data;
}
}
我在上面提到的行的插入部分中找不到它們。它與此有關嗎?
我不想聽起來不耐煩,但我想至少有一條評論,要知道這個問題沒有被遺忘。 – vicrabb 2012-07-30 07:58:00