{"id":21833074,"url":"https://github.com/null-none/googledrivephp","last_synced_at":"2025-03-21T13:45:01.678Z","repository":{"id":146604409,"uuid":"41783704","full_name":"null-none/GoogleDrivePHP","owner":"null-none","description":"Use API Google drive for upload files","archived":false,"fork":false,"pushed_at":"2015-09-02T07:15:03.000Z","size":752,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-26T09:28:38.437Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/null-none.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-02T06:18:14.000Z","updated_at":"2019-07-30T18:20:27.000Z","dependencies_parsed_at":"2023-04-06T22:44:41.905Z","dependency_job_id":null,"html_url":"https://github.com/null-none/GoogleDrivePHP","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/null-none%2FGoogleDrivePHP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/null-none%2FGoogleDrivePHP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/null-none%2FGoogleDrivePHP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/null-none%2FGoogleDrivePHP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/null-none","download_url":"https://codeload.github.com/null-none/GoogleDrivePHP/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244807411,"owners_count":20513633,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-27T19:27:45.360Z","updated_at":"2025-03-21T13:45:01.644Z","avatar_url":"https://github.com/null-none.png","language":"PHP","readme":"# GoogleDrivePHP\nUse API Google drive for upload files\n\n```\ncomposer install\n```\n\nExample code\n\n```\n\u003c?php\nrequire_once 'vendor/google/apiclient/src/Google/Client.php';\nrequire_once 'vendor/google/apiclient/src/Google/Service/Drive.php';\n\n$client = new Google_Client();\n$client-\u003esetClientId('\u003cYOUR_CLIENT_ID\u003e');\n$client-\u003esetClientSecret('\u003cYOUR_CLIENT_SECRET\u003e');\n$client-\u003esetRedirectUri('\u003cYOUR_REGISTERED_REDIRECT_URI\u003e');\n$client-\u003esetScopes(array('https://www.googleapis.com/auth/drive.file'));\n\n$session_start();\n\nif (isset($_GET['code']) || (isset($_SESSION['access_token']) \u0026\u0026 $_SESSION['access_token'])) {\n    if (isset($_GET['code'])) {\n        $client-\u003eauthenticate($_GET['code']);\n        $_SESSION['access_token'] = $client-\u003egetAccessToken();\n    } else\n        $client-\u003esetAccessToken($_SESSION['access_token']);\n\n    $service = new Google_Service_Drive($client);\n\n    $file = new Google_Service_Drive_DriveFile();\n    $file-\u003esetTitle('image.jpg');\n    $file-\u003esetDescription('image');\n    $file-\u003esetMimeType('image/jpeg');\n\n    $data = file_get_contents('image.jpg');\n\n    $createdFile = $service-\u003efiles-\u003einsert($file, array(\n          'data' =\u003e $data,\n          'mimeType' =\u003e 'image/jpeg',\n          'uploadType' =\u003e 'multipart'\n        ));\n\n    print_r($createdFile);\n\n} else {\n    $authUrl = $client-\u003ecreateAuthUrl();\n    header('Location: ' . $authUrl);\n    exit();\n}\n\n?\u003e\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnull-none%2Fgoogledrivephp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnull-none%2Fgoogledrivephp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnull-none%2Fgoogledrivephp/lists"}