Google Drive SDK:在PHP中插入文件导致无标题 [英] Google Drive SDK: Inserting a file results in Untitled in PHP

查看:194
本文介绍了Google Drive SDK:在PHP中插入文件导致无标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道以前的两篇文章:



但除了答案'你确定你使用的是最新版本' ,没有一个提问者回来说如果是或否,或者他们是否设法找到答案。



因为我和他们一样,我使用的是最新的apiDriveService.php ,最近一次修订时间为2012年6月。



数据可以正确找到,但是当您到达在插入行,显然,发生了一些错误。



我不明白w hy为SDK php示例,它似乎正确。



这是Google Api控制台中的问题吗?或者我需要编码的数据在一些特殊的?



编辑:在apiDriveService文件中,我可以看到这一行:

  $ this-> files = new FilesServiceResource($ this,$ this-> serviceName,'files',json_decode('{methods:{
插入:{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: ,location:query},timedTextTrackName:{type:string,location:query},timedTextLanguage:{type:string,location query}},supportsMediaUpload:true,request:{$ ref:File},mediaUpload:{maxSiz e: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}},...);

在我发送的参数中,有数据和mimetype

  $ created = $ apiService->文件 - >插入($ driveFile,array('data'=> $数据,'mimeType'=> $ mimeType)); 

在插入函数中,有一个array_merge和data以及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;


$ / code $ / pre

我没有在插入部分找到它们我上面提到的那条线。是否与此绑定?

解决方案

只需从Google SVN中检查当前API Client。
http://code.google.com/p / google-api-php-client / source / checkout
我们遇到了同样的问题,但在完成svn结帐后,它神奇地工作,并感谢Alain和Claudio对此的迅速回应。 p>

I do know about the two previous posts:

But apart from the answer 'are you sure you're using the latest release', none of the askers have come back to say if yes or no or if they've managed to find an answer.

Because I'm doing the same thing as them, I'm using the latest apiDriveService.php with the last revision dated from June 2012.

The data is correctly found but when you arrive at the insert line, clearly, something wrong happens.

And I don't understand why for the SDK php example, it seems to go correctly.

Is this a problem in the Google Api Console? Or do I need to encode the data in something special?

EDIT: in the apiDriveService file, I can see this line:

$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"}}, ...);

In the parameters I'm sending, there is data and mimetype:

$created = $apiService->files->insert($driveFile, array('data' => $data,'mimeType' => $mimeType));

And in the insert function, there is an array_merge with data and 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;
  }
}

I don't find them in the insert part of the line I've mentionned above. Is it tied to that?

解决方案

Just check out the current API Client from Google SVN. http://code.google.com/p/google-api-php-client/source/checkout We had the same problem but after doing an svn checkout, it magically worked and thanks to Alain and Claudio for their swift response on this.

这篇关于Google Drive SDK:在PHP中插入文件导致无标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆