{"id":2799,"date":"2022-08-30T15:27:52","date_gmt":"2022-08-30T15:27:52","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/02\/16\/google-drive-api-downloadfile-getio-error-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:27:52","modified_gmt":"2022-08-30T15:27:52","slug":"google-drive-api-downloadfile-getio-error-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/google-drive-api-downloadfile-getio-error-collection-of-common-programming-errors\/","title":{"rendered":"Google Drive API downloadFile getIo Error-Collection of common programming errors"},"content":{"rendered":"<p>I want to create a gDrive App. I can get downloadUrl (like as string &#8216;https:\/\/doc-0k-68-docs.googleusercontent.com\/docs\/securesc\/gf6salc3nfs5me1dnqgnp4crl90gg593\/21kfelc8h3l1qvkgskqacnee2pqjt5es\/1343484000000\/14678698184812381901\/14678698184812381901\/0B95t2gVGbZ61Sk0yNlY5TTZObUU?h=16653014193614665626&amp;e=download&amp;gd=true&#8217; (length=251))<\/p>\n<p>But i can&#8217;t download via this link. I guess, must some auth.<\/p>\n<p>i try this functions, i take here<\/p>\n<pre><code>function downloadFile($service, $file) {\n  $downloadUrl = $file-&gt;getDownloadUrl();\n  if ($downloadUrl) {\n    $request = new apiHttpRequest($downloadUrl, 'GET', null, null);\n    $httpRequest = $service-&gt;getIo()-&gt;authenticatedRequest($request);\n    if ($httpRequest-&gt;getResponseHttpCode() == 200) {\n      return $httpRequest-&gt;getResponseBody();\n    } else {\n      \/\/ An error occurred.\n      return null;\n    }\n  } else {\n    \/\/ The file doesn't have any content stored on Drive.\n    return null;\n  }\n}\n<\/code><\/pre>\n<p>i take an error<\/p>\n<p><strong>Call to undefined method apiDriveService::getIo() in &#8230;.<\/strong><\/p>\n<p>please help me. i can&#8217;t found anywhere.<\/p>\n<pre><code>object(apiHttpRequest)[18]\n  protected 'url' =&gt; string 'https:\/\/doc-0k-68-docs.googleusercontent.com\/docs\/securesc\/gf6salc3nfs5me1dnqgnp4crl90gg593\/900384ep39btqvj6j91ssm11lvom8r09\/1343635200000\/14678698184812381901\/14678698184812381901\/0B95t2gVGbZ61Sk0yNlY5TTZObUU?h=16653014193614665626&amp;e=download&amp;gd=true&amp;key=AIzaSyA1qi-3-tqpyzxAXhy5c9_EkVGFNsRZ9Fw' (length=295)\n  protected 'requestMethod' =&gt; string 'GET' (length=3)\n  protected 'requestHeaders' =&gt; \n    array (size=1)\n      'authorization' =&gt; string 'Bearer ya29.AHES6ZTgpamuF6g35HuLj2PW_KH06yZhLLNdNLF_MgaiFGLp' (length=60)\n  protected 'postBody' =&gt; null\n  protected 'userAgent' =&gt; string 'Tahribat google-api-php-client\/0.5.0' (length=36)\n  protected 'responseHttpCode' =&gt; int 404\n  protected 'responseHeaders' =&gt; \n    array (size=10)\n      'server' =&gt; string 'HTTP Upload Server Built on Jul 25 2012 10:54:42 (1343238882)' (length=61)\n      'access-control-allow-origin' =&gt; string '*' (length=1)\n      'access-control-allow-credentials' =&gt; string 'false' (length=5)\n      'access-control-allow-headers' =&gt; string 'authorization' (length=13)\n      'access-control-allow-methods' =&gt; string 'GET,OPTIONS' (length=11)\n      'date' =&gt; string 'Mon, 30 Jul 2012 08:01:31 GMT' (length=29)\n      'expires' =&gt; string 'Mon, 30 Jul 2012 08:01:31 GMT' (length=29)\n      'cache-control' =&gt; string 'private, max-age=0' (length=18)\n      'content-length' =&gt; string '0' (length=1)\n      'content-type' =&gt; string 'text\/html; charset=UTF-8' (length=24)\n  protected 'responseBody' =&gt; boolean false\n  public 'accessKey' =&gt; null\n<\/code><\/pre>\n<p>\/\/\/\/\/\/\/<\/p>\n<pre><code>object(DriveFile)[15]\n  public 'mimeType' =&gt; string 'application\/rar' (length=15)\n  public 'thumbnailLink' =&gt; null\n  protected '__labelsType' =&gt; string 'DriveFileLabels' (length=15)\n  protected '__labelsDataType' =&gt; string '' (length=0)\n  public 'labels' =&gt; \n    object(DriveFileLabels)[16]\n      public 'restricted' =&gt; boolean false\n      public 'hidden' =&gt; boolean false\n      public 'viewed' =&gt; boolean false\n      public 'starred' =&gt; boolean false\n      public 'trashed' =&gt; boolean false\n  protected '__indexableTextType' =&gt; string 'DriveFileIndexableText' (length=22)\n  protected '__indexableTextDataType' =&gt; string '' (length=0)\n  public 'indexableText' =&gt; null\n  public 'etag' =&gt; string '\"WtRjAPZWbDA7_fkFjc5ojsEvE7I\/MTM0MzM1NDI2OTYwMA\"' (length=48)\n  public 'lastModifyingUserName' =&gt; string 'Pskptbt6' (length=8)\n  public 'writersCanShare' =&gt; boolean true\n  public 'id' =&gt; string '0By790Jqkq9pLRDRuUFZ3UWVxdGs' (length=28)\n  public 'title' =&gt; string '1caec72e95949a693dc0e95eeaeb2a9e.rar' (length=36)\n  public 'ownerNames' =&gt; \n    array (size=1)\n      0 =&gt; string 'Pskptbt6' (length=8)\n  public 'sharedWithMeDate' =&gt; null\n  public 'lastViewedByMeDate' =&gt; null\n  protected '__parentsType' =&gt; string 'ParentReference' (length=15)\n  protected '__parentsDataType' =&gt; string 'array' (length=5)\n  public 'parents' =&gt; \n    array (size=0)\n      empty\n  public 'exportLinks' =&gt; null\n  public 'originalFilename' =&gt; string 'Web Elements.rar' (length=16)\n  public 'description' =&gt; null\n  public 'editable' =&gt; boolean false\n  public 'kind' =&gt; string 'drive#file' (length=10)\n  public 'quotaBytesUsed' =&gt; string '30249130' (length=8)\n  public 'fileSize' =&gt; string '30249130' (length=8)\n  public 'createdDate' =&gt; string '2012-07-27T01:55:50.169Z' (length=24)\n  public 'md5Checksum' =&gt; string '595182e10bcc986cc8dcc41a6e945019' (length=32)\n  public 'embedLink' =&gt; null\n  public 'alternateLink' =&gt; string 'https:\/\/docs.google.com\/file\/d\/0By790Jqkq9pLRDRuUFZ3UWVxdGs\/edit' (length=64)\n  public 'permissionsLink' =&gt; null\n  public 'modifiedByMeDate' =&gt; null\n  public 'downloadUrl' =&gt; string 'https:\/\/doc-04-5s-docs.googleusercontent.com\/docs\/securesc\/gf6salc3nfs5me1dnqgnp4crl90gg593\/t1ucp1ub6sdcgk7hdatj1it5m5ntoodh\/1343635200000\/13117762293604295629\/14678698184812381901\/0By790Jqkq9pLRDRuUFZ3UWVxdGs?h=16653014193614665626&amp;e=download&amp;gd=true' (length=251)\n  protected '__userPermissionType' =&gt; string 'Permission' (length=10)\n  protected '__userPermissionDataType' =&gt; string '' (length=0)\n  public 'userPermission' =&gt; \n    object(Permission)[17]\n      public 'withLink' =&gt; null\n      public 'kind' =&gt; string 'drive#permission' (length=16)\n      public 'name' =&gt; null\n      public 'value' =&gt; null\n      public 'id' =&gt; string 'me' (length=2)\n      public 'authKey' =&gt; null\n      public 'etag' =&gt; string '\"WtRjAPZWbDA7_fkFjc5ojsEvE7I\/dLmoyrW_nZG7qLX6EhuNvVbQIq0\"' (length=57)\n      public 'role' =&gt; string 'reader' (length=6)\n      public 'photoLink' =&gt; null\n      public 'type' =&gt; string 'user' (length=4)\n      public 'additionalRoles' =&gt; null\n      public 'selfLink' =&gt; string 'https:\/\/www.googleapis.com\/drive\/v2\/files\/0By790Jqkq9pLRDRuUFZ3UWVxdGs\/permissions\/me' (length=85)\n  public 'fileExtension' =&gt; string 'rar' (length=3)\n  public 'selfLink' =&gt; string 'https:\/\/www.googleapis.com\/drive\/v2\/files\/0By790Jqkq9pLRDRuUFZ3UWVxdGs' (length=70)\n  public 'modifiedDate' =&gt; string '2012-07-27T01:57:49.600Z' (length=24)\n  public 'webContentLink' =&gt; string 'https:\/\/docs.google.com\/uc?id=0By790Jqkq9pLRDRuUFZ3UWVxdGs&amp;export=download' (length=74)\n<\/code><\/pre>\n<p>actually i just want to like this site.<\/p>\n<p>http:\/\/www.gdriveurl.com\/<\/p>\n<p>but, just i create automatically in my website each link.<\/p>\n<ol>\n<li>\n<p>Change this line:<\/p>\n<pre><code> $httpRequest = $service-&gt;getIo()-&gt;authenticatedRequest($request);\n<\/code><\/pre>\n<p>by:<\/p>\n<pre><code> $httpRequest = apiClient::$io-&gt;authenticatedRequest($request);\n<\/code><\/pre>\n<p>I had myself the error and after, by changing the line, I didn&#8217;t have a problem anymore.<\/p>\n<p>$service apparently is concerning apiClient and not apiDriveService.<\/p>\n<\/li>\n<li>\n<pre><code>$request = new Google_HttpRequest($downloadUrl, 'GET', null, null);\n$httpRequest = Google_Client::$io-&gt;authenticatedRequest($request);\n<\/code><\/pre>\n<p>for new library google-api-php-client-0.6.0.tar.gz<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2014-02-16 23:27:09. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I want to create a gDrive App. I can get downloadUrl (like as string &#8216;https:\/\/doc-0k-68-docs.googleusercontent.com\/docs\/securesc\/gf6salc3nfs5me1dnqgnp4crl90gg593\/21kfelc8h3l1qvkgskqacnee2pqjt5es\/1343484000000\/14678698184812381901\/14678698184812381901\/0B95t2gVGbZ61Sk0yNlY5TTZObUU?h=16653014193614665626&amp;e=download&amp;gd=true&#8217; (length=251)) But i can&#8217;t download via this link. I guess, must some auth. i try this functions, i take here function downloadFile($service, $file) { $downloadUrl = $file-&gt;getDownloadUrl(); if ($downloadUrl) { $request = new apiHttpRequest($downloadUrl, &#8216;GET&#8217;, null, null); $httpRequest = $service-&gt;getIo()-&gt;authenticatedRequest($request); [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2799","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2799","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2799"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2799\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2799"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2799"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2799"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}