google-api-php-client

Gmail API Watch() not working

依然范特西╮ 提交于 2019-12-13 14:27:23
问题 I am following Gmail API Push notifications guide given at https://developers.google.com/gmail/api/guides/push. However, when I try to create a new watch from API explorer, it gives following response: { "error": { "errors": [ { "domain": "global", "reason": "invalidArgument", "message": "Invalid topicName does not match projects/google.com:apisexplorerconsole/topics/*" } ], "code": 400, "message": "Invalid topicName does not match projects/google.com:apisexplorerconsole/topics/*" } } My

How to set timeout for google api php client library

拟墨画扇 提交于 2019-12-13 14:17:44
问题 I am using Google's php client library to build an app. Sometimes, Google takes up to 100 seconds to respond to an API request. I'd like to limit the socket timeout to 30 seconds. Anyone know how this is possible? Not seeing any clear examples in the docs and I nothing timeout-related jumped out at me looking at the source. I did find this example in the docs for the Java client, but I can't seem to find the PHP equivalent. Thanks for any help. 回答1: According to this issue you can pass

google service account example returns “Error refreshing the OAuth2 token { “error” : “invalid_grant” }”

谁说我不能喝 提交于 2019-12-13 11:35:25
问题 My goal is to make the simplest query on Google Fusion Tables on behalf of my web app users. For that, I created a service account on google console. Here is the code: // Creating a google client $client = new \Google_Client(); // setting the service acount credentials $serviceAccountName = 'XXXXX.apps.googleusercontent.com'; $scopes= array( 'https://www.googleapis.com/auth/fusiontables', 'https://www.googleapis.com/auth/fusiontables.readonly', ); $privateKey=file_get_contents('/path/to

Google Calendar API on php using service account

不羁的心 提交于 2019-12-13 08:42:53
问题 I have a question about the Google Calendar API. I get the Google Calendar API with PHP and created the new event with service account. If I read the calendar on php progrum again, only the schedule written from php with service account can not be load. What is the cause of the problem? is it a specification that php can not read in a schedule created from php with a service account? Setting information: I am using autoload.php of google-api-php-client-1-master. It is Google calendar V3. In

How to upload files on YouTube using resumable upload API v3

不问归期 提交于 2019-12-13 06:53:06
问题 The following code does not work, how can I use it to upload files on YouTube? $service_url = 'https://www.googleapis.com/upload/youtube/v3/videos?uploadType=resumable&part=snippet,status'; $c = curl_init($service_url); $curl_post_data = array( "Authorization" => $val, "Content-Length" => '275', "Content-Type" => 'application/json; charset=UTF-8', "X-Upload-Content-Length" => '2394849', "X-Upload-Content-Type" => 'video/mov' ); curl_setopt($c, CURLOPT_RETURNTRANSFER, true); curl_setopt($c,

file uploaded with empty content using google drive php api

删除回忆录丶 提交于 2019-12-13 06:42:54
问题 Below is the code. which uploading/creating/inserting a file on the google drive using google drive php api successfully, but after uploading the file it's contents are empty. session_start(); set_include_path("/src/" . PATH_SEPARATOR . get_include_path()); require_once 'Google/Client.php'; require_once 'Google/Service/Drive.php'; $client_id = 'XXXXXX'; $client_secret = 'XXXXXX'; $redirect_uri = 'XXXXXX'; $client = new Google_Client(); $client->setClientId($client_id); $client-

using google-api-php-client not able to create proper signedurl

故事扮演 提交于 2019-12-13 05:24:21
问题 bucketIn my project, I am uploading user's files to cloud storage, so when user wants to download that file I want to generate signedurl from google cloud, to limit access to the files to that specific user only, So I have tried following php code to do that ` function storageURL( $id, $method = 'GET', $duration = 10 ) { $expires = time( ) + $duration*60; $content_type = ($method == 'PUT') ? 'application/x-www-form-urlencoded' : ''; $to_sign = ($method . "\n" . /* Content-MD5 */ "\n" .

How to delete row from Google Sheets using api v4 in PHP

时间秒杀一切 提交于 2019-12-13 04:22:29
问题 I am trying to delete a row in Google Sheets using the Google APIs PHP client library that Google provide for their APIs. Currently I am only able to clear the contents of the row but not delete it: $requestBody = new Google_Service_Sheets_ClearValuesRequest(); $range = 'Form responses 1!C5:H5'; $response = $service->spreadsheets_values->clear($spreadsheetId, $range, $requestBody); The documentation does not explain in any way at all how to delete apart from giving one line of HTTP that has

Adwords API Exclude Content_label on campaign level

风流意气都作罢 提交于 2019-12-13 04:10:50
问题 I've been researching this for a few hours now and still can't figure out a solution. I intend to exclude some content_labels on the campaign level. At first, I followed the API examples but those are for 'CustomerNegativeCriteria' that are account level settings (sidenote, I couldn't find these global settings on the AdWords interface). Then I read more and tried to exclude them using a CampaignCriterion So I'll create my ContentLabel objects in this way: $criterion = new ContentLabel();

how to get user location information using google client api

会有一股神秘感。 提交于 2019-12-13 03:31:57
问题 I implementing google login in my site, I want to access user's location but I am not able to access. I have searched the internet but could not get useful info. authentication code if (!function_exists('curl_reset')) { function curl_reset(&$ch) { $ch = curl_init(); } } require_once __DIR__ . '/google-api-php-client-2.2.0/vendor/autoload.php'; $client = new Google_Client(); $client->setAuthConfig('client_secrets.json'); $redirectURL = 'www.mysite.com/gmail-callback.php'; $client-