google-api-php-client

Google Drive API copy() - 404 error

 ̄綄美尐妖づ 提交于 2019-12-11 13:49:07
问题 I'm using Google Drive API in PHP to manage any files (insert, delete, copy..). Now I need to create a copy of a file in drive folder (insert work fine). My code is the same of Google reference. I'm find the file ID with search parameters and then call the function: $parameters = array(); $parameters['q'] = "title = '".$title."' and mimeType = 'application/vnd.google-apps.spreadsheet'"; $files = $service->files->listFiles($parameters); if (count($files['items'])>0){ $fileId = $files['items']

Bad Request while accesing Gmail API

蓝咒 提交于 2019-12-11 13:43:22
问题 I'm trying to connect to Gmail but server says: Uncaught exception 'Google_Service_Exception' with message 'Error calling GET https://www.googleapis.com/gmail/v1/users/{test}%40gmail.com/messages: (400) Bad Request' in C:\...\google-api-php-client\src\Google\Http\REST.php on line 110 I can't seem to find the problem. Here's the code: $google_accounts = $this->getGoogleAccounts(); if (count($google_accounts) > 0) { require_once $_SERVER['DOCUMENT_ROOT'] . '/include/google-api-php-client/src

Google API and OAuth 2.0

我的未来我决定 提交于 2019-12-11 12:40:08
问题 I'm trying to use google calendar API with php library and i'm facing issues on the authentification of the user to the google api. I have a question. I've seen some come where you had to set the Api key / developer key to the Google_Client object with the method setDeveloperKey(), but i've also seen some people who don't. Could someone explain to me what difference does it make ? The thing i'd like to do is to connect a user who have a google account to my application so he can add, list,

Dynamically Create Folders and Subfolders

喜欢而已 提交于 2019-12-11 12:10:03
问题 I have several scripts in php to create a folder and upload a file to the desired folder, but I can't seem to be able to create new folders, new subfolders or create another function to do this process. Do i have to use a parent/children specific procedure? Here's the functional code I use to create a folder: function getFolderExistsCreate($service, $folderName, $folderDesc) { // Lista el root de drive $files = $service->files->listFiles(); $found = false; // Checa los folders en ciclo

Google API Refresh Token

我与影子孤独终老i 提交于 2019-12-11 12:05:17
问题 I have been trying for the last few hours to print my refresh_token from the initial Google API call (even after de-authorizing and re-authorizing as others have suggested doing) but I still am not having any luck...the API works as expected but I want to set up refreshing functionality so my user does not lose access after token expires (resulting in errors). Currently, the below code sets $_SESSION['refresh_token'] to null. Any help would be greatly appreciated as I have been banging my

Using PHP to access Gmail using Service Account

南笙酒味 提交于 2019-12-11 11:56:50
问题 I am trying to list emails from a standard Gmail account (not a Google Apps account) using OAuth2 and a Service Account (actually, I want to send emails – but that can wait). I have created the Project, created the service account, downloaded the private key, and enabled the Gmail API (and the Calendar API). I can successfully access my calendar using code very similar to the code below. However, I am receiving the following error when attempting to list mail messages. Error refreshing the

Error while processing authentification OAuth2

只愿长相守 提交于 2019-12-11 11:26:31
问题 i have follow this tutorial to get credentials from google but for youtube API scope instead of contact API one. I have tried with this: <?php session_start(); require 'Google/Client.php'; require 'config.php'; //$_SESSION = array(); $client = new Google_Client(); $client->setApplicationName('Test APPS'); $client->setClientId($clientId); $client->setClientSecret($clientSecret); $client->setScopes($scope); $client->setRedirectUri($redirectUri); $client->setAccessType($accessType); if(isset($

How to set curl timeout in Google API PHP client version 2.2.2

眉间皱痕 提交于 2019-12-11 09:31:18
问题 I am trying to set the default curl timeout in the scripts I am using for batch updating users using directory api. Only a handful of users are added before the curl connection times out. I have tried this but it doesn't work with the API v2.2.2 Can someone show me how to update the curl timeout settings using php? Thank you. Here is the code: $groupEmail = "my group email"; require_once realpath(dirname(__FILE__).'/vendor/autoload.php'); $client = new Google_Client(); $client->setAuthConfig(

Google OAuth access token not refresh token NULL

喜欢而已 提交于 2019-12-11 08:24:23
问题 I'm trying to get my access token on my server to use the GMail API from the PHP client library and all I get is NULL after I var_drump the variable I have store the access token in through the getAccessToken(); method. Any idea what I am doing wrong so that how I can an access token? I have a valid auth code in the URL with the code parameter and I don't know why I am getting null when I try to fetch the access token. Any ideas? Here is my code: require_once 'vendor/autoload.php'; $redirect

Google PHP Api Client - I keep getting Error 401: UNAUTHENTICATED

风格不统一 提交于 2019-12-11 08:21:33
问题 I've been struggling with this for hours now, if not days and can't seem to fix it. My Requests to Cloud Functions are being denied with error code: 401: UNAUTHENTICATED. My Code is as follow: putenv('GOOGLE_APPLICATION_CREDENTIALS=' . FIREBASE_SERIVCE_PATH); $client = new Google_Client(); $client->useApplicationDefaultCredentials(); $client->addScope(Google_Service_CloudFunctions::CLOUD_PLATFORM); $httpClient = $client->authorize(); $promise = $httpClient->requestAsync("POST", "