Гугл диск api php

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

License

LookHin/google-drive-api

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

Step 0: Enable Google Drive API Enable Google Drive API

Google Drive API

Step 1: Create OAuth client ID

Google Drive API

Google Drive API

Step 2: Edit Client Id and Client secret in authorize.php and example.php from this code

Google Drive API

Step 3: Authorize (Open http://YOUR_SERVER/google-drive/authorize.php from your browser)

Google Drive API

Step 5: Edit refrest token in example.php from this code

Google Drive API

Google Drive API

What is Folder Id or File Id

include_once("google-drive-api.class.php"); $strClientId pl-s">YOUR_CLIENT_ID"; $strClientSecret pl-s">YOUR_CLIENT_SECRET"; $strRefreshToken pl-s">YOUR_REFRESH_TOKEN"; // Init Drive Object $obj = new GoogleDriveApi($strClientId, $strClientSecret); $obj->setAccessTokenFromRefreshToken($strRefreshToken); // List File From Root Folder $arrFile = $obj->ListFileAndFolder("root"); print_r($arrFile); // # List File From Folder Id //$arrFile = $obj->ListFileAndFolder("_PARENT_FOLDER_ID_"); //print_r($arrFile); // # Create Folder In Root Folder //$obj->CreateFolder("root", "_NEW_FOLDER_NAME_"); // # Create Folder In Parent Folder //$obj->CreateFolder("_PARENT_FOLDER_ID_", "_NEW_FOLDER_NAME_"); // # Delete File & Folder //$obj->Delete("_FILE_OR_FOLDER_ID_"); // # Upload File To Root Folder // $arrResult = $obj->Upload("root", "no-face.png"); // print_r($arrResult); // # Upload File To Parent Folder // $arrResult = $obj->Upload("_PARENT_FOLDER_ID_", "no-face.png"); // print_r($arrResult);

Name : Khwanchai Kaewyos (LookHin)
Email : khwanchai@gmail.com

Читайте также:  Шаблоны для админки html

Copyright (C) 2017 Khwanchai Kaewyos (LookHin)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the «Software»), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED «AS IS», WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Uploading and downloading files (large files and specific folders supported) to your Google Drive using PHP and the Google Drive API. Uses an offline token so that authentication is only needed during setup.

lucastws/Google-Drive-API-PHP-Example

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

Upload and download files from your Google Drive via Google Drive API using PHP.

Читайте также:  Configure java home in windows

This is an improved version of yannisg/Google-Drive-Uploader-PHP with small fixes and changes. Credits also goes to yannisg.

  • Supports offline token so that you don’t need human intervention to authenticate each time script is run;
  • Chunked upload to support large files;
  • Upload to specific folders (check the comment inside «controllerUpload.php»);
  • Download files using IDs (you can test it right away after uploading a file and copying the ID given);
  • Already includes the required Google API in folder «libraries»;
  • Includes a simply and undestandable example in index.php with a file input and submit to a script («controllerUpload.php») that does the upload trick;
  • Includes a simply and undestandable example in index.php with a text input and submit to a script («controllerUpload.php») that does the download trick.
  1. Have your project already set up (if not, do it here: https://console.developers.google.com/cloud-resource-manager);
  2. Have Google Drive API already activated in your project (if not, do it here: https://console.developers.google.com/apis/api/drive.googleapis.com);
  3. Enter OAuth credentials of your project in both «classGdrive.php» and «gdrive_token.php» scripts (get from here: https://console.developers.google.com/apis/credentials);
  4. Certify that «gdrive_token.php» is being loaded in your pages so you can authenticate once and save token locally to file as well as checks if there is no need to authenticate again;
  5. Include «classGdrive.php» in your project and upload files through it (just as the way is used in «controllerUpload.php»).
include_once "classes/classGdrive.php"; require_once "/../gdrive_token.php"; $file = $_FILES["fileToUpload"]; // Name of the file input from the view page $refreshToken = $_SESSION["token"]["refresh_token"]; // Getting the refresh token previously stored in session by gdrive_token.php $gdrive = new gdrive; $gdrive->fileRequest = $file; $gdrive->initialize($refreshToken); $gdrive->processFile();

About

Uploading and downloading files (large files and specific folders supported) to your Google Drive using PHP and the Google Drive API. Uses an offline token so that authentication is only needed during setup.

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Easy to use Google Drive API in PHP

dharmin/easy-google-drive-api-php

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Читайте также:  Возможности язык программирования html

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

Easy Google Drive API PHP

Fast and easy to use Google Drive API for PHP.

  • Easy to setup;
  • Create Folders,Upload files,List files or folders by just calling simple function.
  • Refresh Token added for long lived session
  • isLoggedIn() method added to check access token is available without accessing session variables

Install the dependencies of GoogleAPI by using composer.

Open your favorite Terminal and run these commands.

Open GoogleClient.php and set your credintial details

protected $client_id = ''; protected $client_secret = ''; protected $redirect_uri = '';
require_once 'google.php'; // Include Class File session_start(); //Start the session $google = new GoogleClient(); //Create GoogleClient Object // Check if the user is logged in if(!$google->isLoggedIn())< // Go to Google Login Page header('Location: '.$google->getAuthURL()); exit; > // If the page is redirected from google authentication if(isset($_GET['code']))< // Authenticate and start the session $google->authenticate($_GET['code']); # your code .. >

Always initlize drive before using Drive operation

/** * Create folder at google drive * @param string $parentId folder id in which folder will be created * @param string $folderName folder name to create * @return string id of created folder */ $folderId = $google->createFolder($parentFolderId,$folderName);
/** * Upload file to given folder * @param string $parentId parent folder in which folder will be upload * @param string $filePath file local path of file which will be upload * @param string $fileName file name of the uploaded copy at google drive * @return string id of uploaded file */ $fileId uploadFile($parentId,$filePath,$fileName pl-s">none");
/** * Get the list of files or folders or both from given folder or root * @param string $search complete or partial name of file or folder to search * @param string $parentId parent folder id or root from which the list of files or folders or both will be generated * @param string $type='all' file or folder (files,folders or all) * @return array list of files or folders or both from given parent directory */ $list = listFilesFolders($search,$parentId,$type='all');
  • More ease to use API.
  • Different options of credentials either by initilizing variables or secred.json file.
  • Features like moving and copying one folder to another folder.

Источник

Оцените статью