Thursday, 15 August 2013

Gmail API PHP Client Library - How do you send large attachments using the PHP client library? -


I am using Google's PHP Client Library to send calls to Gmail's API. Using those resources, I can send messages with attachments using code like this:

  public_smessage (Google_Service_Gmail $ gmail, $ raw_message) {log: info ('Gmail API request 'users_messages- & gt; send' '); $ PostBody = new Google_Service_Gmail_Message (); $ PostBody- & gt; SetRaw (Str :: base64_encode_url ($ raw_message)); Return $ gmail-> User_message-> Send ('me', $ postBody, ['uploadType' = & gt; 'multicast']); }  

But I can not understand how I can send attachments attached to some MB for my life I have found that it is necessary to use Multipurpose upload type, but I will tell about it How can it be implemented based on its current version, as I get the following error in the code given above:

  POST https: //www.googleapis. Com / gmail / v1 / users / me / messages / send? UploadType = multipart Error 413 Error in calling: The request unit is too large  

Really good Broad Stroke info, but I'm looking forward to a bit more guidance specific to Google's PHP Client Library.

Edit: Accordingly, the maximum upload size is actually 35 MB. The size specified in my php.ini is sufficient for this, and the request fails as an internal server error from Google 413.

Not familiar with the GMail API, but you were selected to reduce the size of each individual request Must be able to use uploads. Take a look at the file upload sample in the client:

  $ media = new Google_Http_MediaFileUpload ($ client, $ request, 'text / plain', empty, true, $ squared sbabytes); $ Media & gt; SetFileSize (file size (testfile)); $ Position = false; $ Handle = FOPN (testfell, "rb"); While (! $ Position & amp;; feof ($ handle)) {$ chunk = fread ($ handles, $ Chalkyzbytes); $ Position = $ media-> Next Chain ($ Chuck); }  

No comments:

Post a Comment