I got this Fatal Error/Uncaught Error while linking with the Google Ads API. I've used the Github code and downloaded library from composer

Fatal error: Uncaught Error: Class "Google\Ads\GoogleAds\Examples\Utils\ArgumentParser" not found in googleAdword\examples\BasicOperations\GetCampaigns.php:44 Stack trace: #0 googleAdword\examples\BasicOperations\GetCampaigns.php(120): Google\Ads\GoogleAds\Examples\BasicOperations\GetCampaigns::main() #1

Tried all these solutions:

  1. reinstalling the lib, and not through zip downloading at first, but through git clone, and then install through composer etc.
  2. In the sample code of GetAccountInformation, there is a CUSTOMER_ID field that is required before you execute the code.(Already set)

Tag:google-ads-api, php, google-ads-script, ads, api

4 comments.

  1. Justinas

    Downloading ZIP file from GitHub requires you to manually include all required classes. That's why you need autoloader. Good new is that Composer will automatically do that for you:

    In your composer.json add line "googleads/googleads-php-lib": "^57.0.0" (correct package name and version if wrong) under require'd libraries list Run composer update to download newly added library In your code include composer's autoloader require "/path/to/vendor/autoload.php";
    1. Danny

      Yes! Did this, but still get the error.

    2. Danny

      I did everything to resolve above issue and make lots of R&D but issue not resolved. I checked google, many developers got this issue and are searching and commenting regarding this issue but I didn't see "issue resolved" Please provide me valid working code that can I used in my api request.

    3. Justinas

      Since class namespace includes Examples, then try runing composer install --dev

Add a new comment.