{"id":23133906,"url":"https://github.com/samiaraboglu/google-api-client-php-bundle","last_synced_at":"2026-04-28T08:03:49.309Z","repository":{"id":62539740,"uuid":"140248795","full_name":"samiaraboglu/google-api-client-php-bundle","owner":"samiaraboglu","description":"Symfony Google Api Bundle","archived":false,"fork":false,"pushed_at":"2019-08-03T12:48:00.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-18T17:22:04.718Z","etag":null,"topics":["api","google","google-analytics","google-api","symfony","symfony-bundle"],"latest_commit_sha":null,"homepage":"","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/samiaraboglu.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":"2018-07-09T07:40:34.000Z","updated_at":"2019-08-03T12:48:02.000Z","dependencies_parsed_at":"2022-11-02T15:45:33.758Z","dependency_job_id":null,"html_url":"https://github.com/samiaraboglu/google-api-client-php-bundle","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/samiaraboglu/google-api-client-php-bundle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samiaraboglu%2Fgoogle-api-client-php-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samiaraboglu%2Fgoogle-api-client-php-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samiaraboglu%2Fgoogle-api-client-php-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samiaraboglu%2Fgoogle-api-client-php-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samiaraboglu","download_url":"https://codeload.github.com/samiaraboglu/google-api-client-php-bundle/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samiaraboglu%2Fgoogle-api-client-php-bundle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32371675,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-27T20:07:02.737Z","status":"online","status_checked_at":"2026-04-28T02:00:07.250Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["api","google","google-analytics","google-api","symfony","symfony-bundle"],"created_at":"2024-12-17T12:08:43.850Z","updated_at":"2026-04-28T08:03:49.260Z","avatar_url":"https://github.com/samiaraboglu.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# google-api-client-php-bundle\n\n[![Latest Stable Version](https://poser.pugx.org/samiaraboglu/google-api-client-php-bundle/v/stable)](https://packagist.org/packages/samiaraboglu/google-api-client-php-bundle)\n[![Total Downloads](https://poser.pugx.org/samiaraboglu/google-api-client-php-bundle/downloads)](https://packagist.org/packages/samiaraboglu/google-api-client-php-bundle)\n[![License](https://poser.pugx.org/samiaraboglu/google-api-client-php-bundle/license)](https://packagist.org/packages/samiaraboglu/google-api-client-php-bundle)\n\nUse the [Google APIs Client Library for PHP](https://github.com/google/google-api-php-client).\n\n### Download the Bundle\n\n```console\n$ composer require samiaraboglu/google-api-client-php-bundle\n```\n\n### Enable the Bundle\n\nRegistered bundles in the `app/AppKernel.php` file of your project:\n\n```php\n\u003c?php\nclass AppKernel extends Kernel\n{\n    public function registerBundles()\n    {\n        $bundles = array(\n            // ...\n            new Samiax\\GoogleApiBundle\\SamiaxGoogleApiBundle(),\n        );\n        // ...\n    }\n    // ...\n}\n```\n\n### Config\nAdd this to config.yml:\n\n```yaml\nsamiax_google_api:\n    credential_file:    \"%kernel.root_dir%/config/google-api-client-php/client_credentials.json\"\n    application_name:   \"APPLICATION_NAME\"\n```\n\n### Example 1 - Google Analytics\nGet the session count from google analytics.\n\n```php\n/**\n * @Route(\"/google/analytics\", name=\"google_analytics\")\n */\npublic function googleAnalyticsAction(Request $request)\n{\n    $service = $this-\u003eget('samiax_google_api.google_client');\n\n    $googleClient = $service-\u003egetGoogleClient();\n    $googleClient-\u003esetScopes(['https://www.googleapis.com/auth/analytics.readonly']);\n\n    $analytics = $service-\u003eanalytics();\n\n    // Create the DateRange object.\n    $dateRange = new \\Google_Service_AnalyticsReporting_DateRange();\n    $dateRange-\u003esetStartDate(\"1daysAgo\");\n    $dateRange-\u003esetEndDate(\"1daysAgo\");\n\n    // Create the Metrics object.\n    $sessions = new \\Google_Service_AnalyticsReporting_Metric();\n    $sessions-\u003esetExpression(\"ga:sessions\");\n    $sessions-\u003esetAlias(\"sessions\");\n\n    // Create the ReportRequest object.\n    $request = new \\Google_Service_AnalyticsReporting_ReportRequest();\n    $request-\u003esetViewId(\"{VIEW_ID}\");\n    $request-\u003esetDateRanges($dateRange);\n    $request-\u003esetMetrics([$sessions]);\n\n    $body = new \\Google_Service_AnalyticsReporting_GetReportsRequest();\n    $body-\u003esetReportRequests([$request]);\n\n    echo $analytics-\u003ereports-\u003ebatchGet($body)-\u003egetReports()[0]-\u003egetData()-\u003egetTotals()[0]-\u003egetValues()[0];\n\n    return new Response();\n}\n```\n\n### Example 2 - Google Product Feed\nGet the product feeds.\n\n```php\n/**\n * @Route(\"/google/content/auth\", name=\"google_content_auth\")\n */\npublic function googleContentAuthAction(Request $request)\n{\n    $service = $this-\u003eget('samiax_google_api.google_client');\n\n    $googleClient = $service-\u003egetGoogleClient();\n    $googleClient-\u003esetRedirectUri($request-\u003egetSchemeAndHttpHost() . $request-\u003egetBaseUrl() . $request-\u003egetPathInfo());\n    $googleClient-\u003esetScopes('https://www.googleapis.com/auth/content');\n\n    if ($request-\u003equery-\u003eget('code')) {\n        $googleClient-\u003eauthenticate($request-\u003equery-\u003eget('code'));\n\n        $session = $this-\u003econtainer-\u003eget('session');\n        $session-\u003eset('google_content_access_token', $googleClient-\u003egetAccessToken());\n\n        return $this-\u003eredirect(filter_var($this-\u003egenerateUrl('google_content'), FILTER_SANITIZE_URL));\n    }\n\n    return $this-\u003eredirect($googleClient-\u003ecreateAuthUrl());\n}\n\n/**\n * @Route(\"/google/content\", name=\"google_content\")\n */\npublic function googleContentAction()\n{\n    $session = $this-\u003econtainer-\u003eget('session');\n\n    $accessToken = $session-\u003eget('google_content_access_token');\n\n    if (!$accessToken) {\n        return $this-\u003eredirect($this-\u003egenerateUrl('google_content_auth'));\n    }\n\n    $service = $this-\u003eget('samiax_google_api.google_client');\n\n    $googleClient = $service-\u003egetGoogleClient();\n    $googleClient-\u003esetAccessToken($accessToken);\n\n    $shoppingContent = $service-\u003eshoppingContent();\n\n    $products = $shoppingContent-\u003eproducts-\u003elistProducts({MERCHANT_ID});\n\n    var_dump($products);\n\n    return new Response();\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamiaraboglu%2Fgoogle-api-client-php-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamiaraboglu%2Fgoogle-api-client-php-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamiaraboglu%2Fgoogle-api-client-php-bundle/lists"}