Skip to main content
100%

Gist 4506471

✓ Published0🌍 Public
SStanpol
Last edited May 1, 2012
Created on Jan 10, 2013

This example demonstrates a PHP script that uploads a PDF file to Google Drive using the Drive API, showing the authentication and file-insertion workflow. The code relies on the Google API client libraries (`apiClient`, `apiOAuth2`, `apiDriveService`) and `parse_ini_file` for configuration. It first runs an OAuth 2.0 authentication flow by printing a URL for the user to visit, then saves the returned token to a JSON file for reuse. After authentication, it creates a `DriveFile` object with a PDF mime type and calls `$service->files->insert` to upload the local `test.pdf` file, printing the resulting file metadata.

AI-generated description

Similar vizzes