<tfoot id='2bOtZ'></tfoot>
      <legend id='2bOtZ'><style id='2bOtZ'><dir id='2bOtZ'><q id='2bOtZ'></q></dir></style></legend>

      <i id='2bOtZ'><tr id='2bOtZ'><dt id='2bOtZ'><q id='2bOtZ'><span id='2bOtZ'><b id='2bOtZ'><form id='2bOtZ'><ins id='2bOtZ'></ins><ul id='2bOtZ'></ul><sub id='2bOtZ'></sub></form><legend id='2bOtZ'></legend><bdo id='2bOtZ'><pre id='2bOtZ'><center id='2bOtZ'></center></pre></bdo></b><th id='2bOtZ'></th></span></q></dt></tr></i><div id='2bOtZ'><tfoot id='2bOtZ'></tfoot><dl id='2bOtZ'><fieldset id='2bOtZ'></fieldset></dl></div>

      <small id='2bOtZ'></small><noframes id='2bOtZ'>

        • <bdo id='2bOtZ'></bdo><ul id='2bOtZ'></ul>

        将文件提交到 Google Drive

        Submitting file to Google drive(将文件提交到 Google Drive)
        1. <legend id='sZVOO'><style id='sZVOO'><dir id='sZVOO'><q id='sZVOO'></q></dir></style></legend>
            • <bdo id='sZVOO'></bdo><ul id='sZVOO'></ul>
            • <tfoot id='sZVOO'></tfoot>

                  <i id='sZVOO'><tr id='sZVOO'><dt id='sZVOO'><q id='sZVOO'><span id='sZVOO'><b id='sZVOO'><form id='sZVOO'><ins id='sZVOO'></ins><ul id='sZVOO'></ul><sub id='sZVOO'></sub></form><legend id='sZVOO'></legend><bdo id='sZVOO'><pre id='sZVOO'><center id='sZVOO'></center></pre></bdo></b><th id='sZVOO'></th></span></q></dt></tr></i><div id='sZVOO'><tfoot id='sZVOO'></tfoot><dl id='sZVOO'><fieldset id='sZVOO'></fieldset></dl></div>

                    <tbody id='sZVOO'></tbody>

                  <small id='sZVOO'></small><noframes id='sZVOO'>

                  本文介绍了将文件提交到 Google Drive的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我试图将文件提交到 Google 云端硬盘.虽然文件已上传到驱动器,但点击接受按钮后出现错误.

                  I was trying to submit file to Google Drive. Though the file is uploaded to drive, I am getting error after hitting accept button.

                  <?php
                  require_once 'google-api-php-client/src/Google_Client.php';
                  require_once 'google-api-php-client/src/contrib/Google_DriveService.php';
                  
                  $client = new Google_Client();
                  // Get your credentials from the console
                  $client->setClientId('YOUR_CLIENT_ID');
                  $client->setClientSecret('YOUR_CLIENT_SECRET');
                  $client->setRedirectUri('http://localhost/pdf/quickstart.php');
                  $client->setScopes(array('https://www.googleapis.com/auth/drive'));
                  
                  $service = new Google_DriveService($client);
                  
                  $authUrl = $client->createAuthUrl();
                  
                  //Request authorization
                  print "Please visit:
                  $authUrl
                  
                  ";
                  print "Please enter the auth code:
                  ";
                  $authCode = trim(fgets(STDIN));
                  
                  // Exchange authorization code for access token
                  $accessToken = $client->authenticate($authCode);
                  $client->setAccessToken($accessToken);
                  
                  //Insert a file
                  $file = new Google_DriveFile();
                  $file->setTitle('My document');
                  $file->setDescription('A test document');
                  $file->setMimeType('text/plain');
                  
                  $data = file_get_contents('document.txt');
                  
                  $createdFile = $service->files->insert($file, array(
                        'data' => $data,
                        'mimeType' => 'text/plain',
                      ));
                  
                  print_r($createdFile);
                  ?>
                  

                  错误信息:

                  注意:使用未定义的常量 STDIN - 在 C:LocalServerhtdocspdfquickstart.php 中第 18 行假定为STDIN"

                  Notice: Use of undefined constant STDIN - assumed 'STDIN' in C:LocalServerhtdocspdfquickstart.php on line 18

                  警告:fgets() 期望参数 1 为资源,字符串在 C:LocalServerhtdocspdfquickstart.php 中第 18 行

                  Warning: fgets() expects parameter 1 to be resource, string given in C:LocalServerhtdocspdfquickstart.php on line 18

                  如何修复

                  推荐答案

                  STDIN 是一个命令行指令,它不是一个直接有效的 php 语句..我所做的是:

                  STDIN is a command line instruction and it isn't a direct valid php statement .. What i did was :

                  $client = new Google_Client();
                  // Get your credentials from the console
                  $client->setClientId('**********************');
                  $client->setClientSecret('*********');
                  $client->setRedirectUri('*********');
                  $client->setScopes(array('https://www.googleapis.com/auth/drive'));
                  
                  $authUrl = $client->createAuthUrl();
                  print $authurl
                  
                  $authCode = ''; // insert the verification code that you get after going to url in $authurl
                  file_put_contents('token.json', $client->authenticate($authCode));
                  

                  执行这么多后,您将在 json 文件 token.json 中获得您的身份验证信息……您可以使用以下内容上传……:

                  After executing this much you'll get your authentication info in the json file token.json ... And you can use the following to upload ... :

                  $service = new Google_DriveService($client);
                  
                  $client->setAccessToken(file_get_contents('token.json'));
                  
                  //Insert a file 
                      ..... // rest the same
                  

                  一旦你得到你的 json 不要再次运行顶级代码......每次上传/下载都使用 token.json ....

                  Once you get your json don't run the top codes again ... Just use the token.json everytime to upload/download ....

                  这篇关于将文件提交到 Google Drive的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                    <bdo id='VRCMC'></bdo><ul id='VRCMC'></ul>
                    <i id='VRCMC'><tr id='VRCMC'><dt id='VRCMC'><q id='VRCMC'><span id='VRCMC'><b id='VRCMC'><form id='VRCMC'><ins id='VRCMC'></ins><ul id='VRCMC'></ul><sub id='VRCMC'></sub></form><legend id='VRCMC'></legend><bdo id='VRCMC'><pre id='VRCMC'><center id='VRCMC'></center></pre></bdo></b><th id='VRCMC'></th></span></q></dt></tr></i><div id='VRCMC'><tfoot id='VRCMC'></tfoot><dl id='VRCMC'><fieldset id='VRCMC'></fieldset></dl></div>
                    <tfoot id='VRCMC'></tfoot>

                            <tbody id='VRCMC'></tbody>
                          <legend id='VRCMC'><style id='VRCMC'><dir id='VRCMC'><q id='VRCMC'></q></dir></style></legend>
                        • <small id='VRCMC'></small><noframes id='VRCMC'>