googleads / google-ads-php

Google Ads API Client Library for PHP
https://developers.google.com/google-ads/api/docs/client-libs/php
Apache License 2.0
288 stars 260 forks source link

Where to place google_ads_php.ini configuration file in the server live project ? #949

Closed khushal21 closed 8 months ago

khushal21 commented 1 year ago

Hello everyone, I am creating an application to view the campaign data using Google ads PHP client library. In localhost the code is working fine and also showing required result. But when I hosted project on server various error where found due to the mismatch in path of google_ads_php.ini config file. Error are below

PHP Fatal error:  Uncaught InvalidArgumentException: Config file not found as specified: 'https://domainname.in/google-ads-php/google_ads_php.ini'. Home directory could not be located so it was not searched. in /home1/folder/public_html/domain_name.in/google-ads-php/src/Google/Ads/GoogleAds/Lib/ConfigurationLoader.php:72
Stack trace:
#0 /home1/folder/public_html/domain_name.in/google-ads-php/src/Google/Ads/GoogleAds/Lib/AbstractGoogleAdsBuilder.php(57): Google\Ads\GoogleAds\Lib\ConfigurationLoader->fromFile('https://domain...')
#1 /home1/folder/public_html/domainname.in/google-ads-php/GetCampaigns.php(52): Google\Ads\GoogleAds\Lib\AbstractGoogleAdsBuilder->fromFile('https://domainname...')
#2 /home1/folder/public_html/domainname.in/ga-get-campaign.php(13): Google\Ads\GoogleAds\Examples\BasicOperations\GetCampaigns::main()
#3 {main}
  thrown in /home1/folder/public_html/domainname.in/google-ads-php/src/Google/Ads/GoogleAds/Lib/ConfigurationLoader.php on line 72

Please help me find that how can i solve this error on server ?

fiboknacky commented 1 year ago

The logic is here. To find your home directory, you can start by running getenv('HOME'). Once you know the home directory, you can just put your google_ads_php.ini there without setting anything special.

fiboknacky commented 8 months ago

Closing due to inactivity.