Category : google-api

I recently tried to fetch gender in my laravel project by google OAuth by using the scope inside services.php -> google => [scopes => [‘https://www.googleapis.com/auth/user.gender.read’]]. I don’t understand why, but it didn’t work it threw me an error abstractProvider.php:236 i.e InvalidStateException. I researched on it found that we must add stateless() in Socialite::driver($provider)->user(); like Socialite::driver($provider)->stateless()->user();. ..

Read more

If i make a request like this in spatie analytics: $analyticsData = Analytics::performQuery( Period::days(1), ‘ga:sessions’, [ ‘metrics’ => ‘ga:sessions, ga:pageviews’, ‘dimensions’ => ‘ga:yearMonth’ ] ); what does "days(1) refer to ? is it from 00:00 to 23:59 or from 24 hour ago until now? i tried reading the start and end time in the result ..

Read more

strong textI am getting different google api results when running this function on locally in comparison to my server. public static function debug(){ $date = Carbon::now(‘Europe/Berlin’); $date->setISODate(2021,25); $start = $date->copy()->startOfWeek(); $end = $date->copy()->endOfWeek(); $ga= Analytics::performQuery( Period::create($start , $end), ‘ga:pageviews’, [ ‘metrics’ => ‘ga:pageviews’, ‘dimensions’ => ‘ga:date’, ‘filters’ => ‘ga:pagePath=~/page1*,ga:pagePath=~/page2*,ga:pagePath=~/page3*,ga:pagePath=~/page34,ga:pagePath=~/page5*’ ] ); return $ga; } Results ..

Read more

I am using this library : https://github.com/spatie/laravel-analytics I am trying to figure out how to do a User Activity request as documented here: https://developers.google.com/analytics/devguides/reporting/core/v4/user-reporting. I know that you can make custom reports with laravel analytics with ‘Analytics::perfomQuery’. I cant seem to find the right metrics and dimensions to get the request right. I have tried ..

Read more

{ "error": { "errors": [ { "domain": "global", "reason": "required", "message": "Login Required", "locationType": "header", "location": "Authorization" } ], "code": 401, "message": "Login Required" } } GOOGLE_CLIENT_ID=458149355420-p1aj58dq7is4j9bqlfig21l6qbc7uhml.apps.googleusercontent.com GOOGLE_CLIENT_SECRET=IsY0PF_ZW6Rm7SEtIciIZ-BD GOOGLE_DRIVE_REFRESH=4/0AY0e-g6g9CFaHtE1Qyo5pa5SoUjvJI57V-iTnjQz8WUqr0TXhmeoMMdsmn9i7NnTfzTbyA GOOGLE_DRIVE_FOLDER_ID=1MTeZiLnZLryyMdJ5-dT0O3KJGM8DHOpU ‘google’=>[ ‘driver’=>’google’, ‘clientId’=>env("GOOGLE_CLIENT_ID"), ‘clientSecret’=>env("GOOGLE_CLIENT_SECRET"), ‘refreshToken’ =>env("GOOGLE_DRIVE_REFRESH"), ‘folderId’=>env("GOOGLE_DRIVE_FOLDER_ID"), ], Storage::extend("google",function($app, $config){ $client = new Google_Client; $client->setClientID($config[‘clientId’]); $client->setClientSecret($config[‘clientSecret’]); $client->refreshToken($config[‘refreshToken’]); $service = new Google_Service_Drive($client); $adapter = new GoogleDriveAdapter($service, ..

Read more

The project I’m working on would ideally scan every delivered email to "[email protected]" then forward every email to gmail. If there is attachment with particular extension it would be extracted and stored on my app’s server for further examination. From my research I could use Google developer API https://developers.google.com/gmail/api/reference/rest/v1/users.messages.attachments/get#examples With this official library https://github.com/googleapis/google-api-php-client Or ..

Read more

I’m trying to listen for subscription changes (new and existing) of my Google Play app on the server. Here’s the code I’m using. This uses the google/cloud-pubsub composer package: $projectId = ‘app-name’; $keyFile = file_get_contents(storage_path(‘app/app-name.json’)); $pubsub = new PubSubClient([ ‘projectId’ => $projectId, ‘keyFile’ => json_decode($keyFile, true) ]); $httpPostRequestBody = file_get_contents(‘php://input’); $requestData = json_decode($httpPostRequestBody, true); info(json_encode($requestData)); ..

Read more

I’m trying to listen for subscription changes (new and existing) of my Google Play app on the server. Here’s the code I’m using. This uses the google/cloud-pubsub composer package: $projectId = ‘app-name’; $keyFile = file_get_contents(storage_path(‘app/app-name.json’)); $pubsub = new PubSubClient([ ‘projectId’ => $projectId, ‘keyFile’ => json_decode($keyFile, true) ]); $httpPostRequestBody = file_get_contents(‘php://input’); $requestData = json_decode($httpPostRequestBody, true); info(json_encode($requestData)); ..

Read more

when I wanna login with google account, I receive this error, ClientException Client error: GET https://www.googleapis.com/plus/v1/people/me?prettyPrint=false resulted in a 403 Forbidden response: <meta name=viewport content="initial-scale=1, minimum-scale=1, w (truncated…) in RequestException.php line 113 public function redirectToProvider() { return Socialite::driver(‘google’)->redirect(); } public function handleProviderCallback() { $social_user = Socialite::driver(‘google’)->user(); $user = User::whereEmail($social_user->getEmail())->first(); if( ! $user ) { $user ..

Read more

I’m trying to use laravel and google analytics to be able to build a report, the problem I’m getting is this { "error": { "code": 400, "message": "CLIENT_ID: {my_client_id} not found.", "errors": [ { "message": "CLIENT_ID: {my_client_id} not found.", "domain": "global", "reason": "badRequest" } ], "status": "INVALID_ARGUMENT" } } Here is my code <?php namespace ..

Read more

I’m using laravel 8 and I’m trying to get a report from google I’m hoping that I’m close, but I’m stuck on this error. > (search) unknown parameter: ‘activityTime’ I’m using these documents to try and get what I need. https://developers.google.com/analytics/devguides/reporting/core/v4/quickstart/service-php https://developers.google.com/analytics/devguides/reporting/core/v4/rest/v4/userActivity/search What I’m trying to do is get a report that will have these ..

Read more

I have used the below package for GoogleAd.Using below package I can only get single account data at a time. But I need multiple account data in single request. How can i do that ? Package link : https://github.com/Edujugon/laravel-google-ads // Code $ads->session([ ‘developerToken’ => ‘token’, ‘clientCustomerId’ => ‘id’ ]); Currently i am passing single id ..

Read more

$user = Socialite::driver(‘google’)->user(); // Set token for the Google API PHP Client $google_client_token = [ ‘access_token’ => $user->token, ‘refresh_token’ => $user->refreshToken, ‘expires_in’ => $user->expiresIn ]; $client = new Google_Client(); $client->setApplicationName(“Laravel”); $client->setDeveloperKey(env(‘GOOGLE_SERVER_KEY’)); $client->setAccessToken(json_encode($google_client_token)); $client->setScopes(Google_Service_Fitness::FITNESS_ACTIVITY_READ); $fitness_service = new Google_Service_Fitness($client); $dataSources = $fitness_service->users_dataSources; $dataSets = $fitness_service->users_dataSources_datasets; $listDataSources = $dataSources->listUsersDataSources(“me”); dd($dataSets); I tried this but it always ended giving ..

Read more