google-api-php-client

Google OAuth 2.0 “error” : “redirect_uri_mismatch”

非 Y 不嫁゛ 提交于 2019-12-03 00:37:34
I spend already one day, crashed one glass and I am really angry about it, I do not understand what google want from me, and what is wrong. I've enabled Google+ Api in developers console , created new OAuth Client ID $ch = curl_init('https://accounts.google.com/o/oauth2/token'); curl_setopt($ch,CURLOPT_POSTFIELDS,'code=4%2FPp1GWqC6PIr3wNYrZ5kK4T9oitxBoo0fBqBrVNQfE-g.ElKDUjQ7E28SoiIBeO6P2m-0RPaolgI&grant_type=authorization_code&redirect_uri=https%3A%2F%2Fmyprivatedomain.local.com%2Foauth2callback&client_id=%mycliet_id%&client_secret=%mysecret%'); curl_setopt($ch,CURLOPT_POST,1); curl_setopt($ch

Google Analytics - Access api without login

点点圈 提交于 2019-12-02 22:39:18
I had successfully configured google analytics api and get successful data. I want to access analytics api without gmail login. i.e. I will hard code credentials to for login, but how to do it with PHP? Is there any api function to achive this task (for PHP) Thanks! The Hello Analytics API: PHP Quickstart Guide for Service Accounts will walk you through the steps necessary to create and add a service account to your existing Google Analytics Account/Property/View. Once you download have the php client libs and the p12 file downloaded from developer console you can create an authorized

How to redirect after google login using codeigniter?

让人想犯罪 __ 提交于 2019-12-02 17:26:43
问题 controller: public function login() { if($this->session->userdata('loggedIn') == true) { redirect('profile'); } if(isset($_GET['code'])) { if($this->google->getAuthenticate()) { $gpInfo = $this->google->getUserInfo(); $userDatas['oauth_provider'] = 'google'; $userDatas['oauth_uid'] = $gpInfo['id']; $userDatas['name'] = $gpInfo['given_name'].' '.$gpInfo['family_name']; $userDatas['email'] = $gpInfo['email']; $userDatas['user_image'] = !empty($gpInfo['picture'])?$gpInfo['picture']:''; $userID =

Google API Fatal error: Uncaught LogicException: refresh token must be passed in or set as part of setAccessToken

旧街凉风 提交于 2019-12-02 10:53:51
Working with the PHP Quickstart code, I found a problem: when the token needs to be refreshed, the code returns the following error: Fatal error: Uncaught LogicException: refresh token must be passed in or set as part of setAccessToken in /app/vendor/google/apiclient/src/Google/Client.php:258 Stack trace: #0 /app/gmail.php(32): Google_Client->fetchAccessTokenWithRefreshToken(NULL) #1 /app/test.php(14): getClient() #2 {main} thrown in /app/vendor/google/apiclient/src/Google/Client.php on line 258 I modified the getClient() function like this: function getClient() { $client = new Google_Client()

Hide Sheets with Google PHP SpreadSheets client

只谈情不闲聊 提交于 2019-12-02 09:17:15
问题 I am using the following code to hide some sheets of a spreadsheet. I use php client library. My target is to export only the desired sheets into a PDF file. Since there is not method to achieve that, I am trying to hide the undesired sheets and then export the spreadhseet with the sheet I need to send by email. But all there requests are failing. Anyone knows the reason? Thank you! function hideSheets($spreadsheetId, $sheetIds) { // Get the sheet service. global $sheet_service; $requestBody

Upload video to youtube using php client library v3

眉间皱痕 提交于 2019-12-02 07:32:16
I am trying to upload a video to youtube using client library v3. The v3 library is experimental and does not have much documentation (samples provided does not include youtube) I have properly authenticated user with oauth 2.0. And when I have access token, I am trying with this code. if ($client->getAccessToken()) { $snippet = new Google_VideoSnippet(); $snippet -> setTitle = "Demo title"; $snippet -> setDescriptio = "Demo descrition"; $snippet -> setTags = array("tag1","tag2"); $snippet -> setMimeType = 'video/quicktime'; $video = new Google_Video(); $video -> setSnippet($snippet); // Not

Hide Sheets with Google PHP SpreadSheets client

我的梦境 提交于 2019-12-02 06:16:22
I am using the following code to hide some sheets of a spreadsheet. I use php client library. My target is to export only the desired sheets into a PDF file. Since there is not method to achieve that, I am trying to hide the undesired sheets and then export the spreadhseet with the sheet I need to send by email. But all there requests are failing. Anyone knows the reason? Thank you! function hideSheets($spreadsheetId, $sheetIds) { // Get the sheet service. global $sheet_service; $requestBody = new Google_Service_Sheets_BatchUpdateSpreadsheetRequest(); $requests = array(); foreach ($sheetIds as

access user calendar with service account

南笙酒味 提交于 2019-12-02 04:22:11
问题 I have a php application on my intranet that needs to add events in the calenders of my users. I followed the following instructing https://developers.google.com/+/domains/authentication/delegation I setup the google-api-php client and used the example service-accounts.php as my starting point. $client_id = 'rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr.apps.googleusercontent.com'; $service_account_name = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy@developer.gserviceaccount.com'; $key_file_location =

Uncaught exception 'InvalidArgumentException' with message ' on Google API

断了今生、忘了曾经 提交于 2019-12-02 04:06:33
问题 I have copied the code in their documentation on this site: here. I have changed the JSON on these below. I have generated a fresh files on API on the composer, but I am still having some issues. I'm not sure what have I done wrong. Does this mean their API is way too buggy? Here is the demo link: demo define('APPLICATION_NAME', 'Ashima'); define('CREDENTIALS_PATH', '/mycredentials.json'); define('CLIENT_SECRET_PATH', __DIR__ .'/mysecret.apps.googleusercontent.com.json'); Error: Fatal error:

Google Cal API - Script to Check Events

心已入冬 提交于 2019-12-02 02:35:46
I want to build a script that will check a Authenticated User's Google Calendar via the Google Calendar PHP Client. I was able to build a simple page that lets a user Auth and give permission to the Calendar Events. I receive a token and then grab a 15 upcoming events via: $googleCal = new Google_Service_Calendar($googleClient); $results = $googleCal->events->listEvents($calendarId, $optParams); But what I'm struggling with is how to save this so I can have a script check this everyday to see if there were new events added. I think what I have is close just struggling to get over the finish