googleads-php-lib icon indicating copy to clipboard operation
googleads-php-lib copied to clipboard

Fatal error: Class 'Google\AdsApi\Common\OAuth2TokenBuilder' not found

Open steponafish opened this issue 8 years ago • 14 comments

I didn't want to add to the previous issue because I think it's different. I have gone through each step using Composer to get these files. I have uploaded them to a website and have moved the adsapi_php.ini file to a new directory. I am testing out GetCampaign.php but I'm getting this error: "Fatal error: Class 'Google\AdsApi\Common\OAuth2TokenBuilder' not found".

If I include the autoload.php file I get a different error that I'm missing clientID, refreshToken and clientSecret, but I have those in my adsapi_php.ini file.

Any help would be great!

screen shot 2018-05-04 at 2 18 30 pm

steponafish avatar May 04 '18 20:05 steponafish

Have you moved all the vendor/ directory generated after you install via Composer to the new place too? And what's in your '/../../adwords/autoload.php'? Generally, it's needed to be the vendor autoload, not the one we write by ourselves.

Best, Knack

fiboknacky avatar May 05 '18 03:05 fiboknacky

I have renamed the directory to adwords and moved it to my website via ftp after I downloaded all the files via Composer. Here is my autoload file. My adsapi_php.ini and autoload are in the same directory (/adwords/)

screen shot 2018-05-07 at 9 03 22 am

steponafish avatar May 07 '18 15:05 steponafish

From the error message, it looks like your autoloading is not functioning correctly. Does it work on your local machine? Is it possible to run composer on the server instead?

fiboknacky avatar May 07 '18 15:05 fiboknacky

I don't even know how to run it through my local machine...

No it's not possible to run composer on the server where the website is being hosted.

steponafish avatar May 07 '18 15:05 steponafish

Can you download examples and try on local machine first? There are instructions in README.md in the tar file there that you can follow.

By the way, why do you need to rename the vendor directory?

fiboknacky avatar May 07 '18 15:05 fiboknacky

I have the examples in the vendor directory already on my local machine. I just don't know how to run them... (I'm learning Adwords API).

I am also running Google Analytics Reporting API on the same website and it uses the directory Vendor and I didn't want to mix the two API's into one.

steponafish avatar May 07 '18 15:05 steponafish

Everything is written in README, so please read through the whole guide first. :) If anything that you need is missing, please let us know.

For example, to run an example, you can follow these steps. Please let me know first if you can run it on your local machine.

For the vendor directory, if you have one composer.json file for your project and you do composer require for each GitHub repo, you don't need (and actually shouldn't) separate the vendor directories. This can be possible cause why your project fails to detect OAuth2TokenBuilder.

fiboknacky avatar May 07 '18 15:05 fiboknacky

Would I have to redownload the API via Composer to get a new autoload?

steponafish avatar May 07 '18 15:05 steponafish

I'm getting a "Could not open input file: examples/AdWords/v201710/BasicOperations/GetCampaigns.php"

steponafish avatar May 07 '18 15:05 steponafish

@fiboknacky, So I should combine my vendor directories? What would I need to put into my composer.json?

steponafish avatar May 07 '18 20:05 steponafish

Hello @steponafish

Let's tackle one issue at a time. :)

Would I have to redownload the API via Composer to get a new autoload? I'm getting a "Could not open input file: examples/AdWords/v201710/BasicOperations/GetCampaigns.php"

I suppose you get started cleanly in your local machine. So, use any location in your computer that doesn't contain any files.

And have you followed the steps I mentioned closely? In what step did you get that error? The last one? If so, can you describe your directory structure? What are in your directory?

fiboknacky avatar May 08 '18 02:05 fiboknacky

I have successfully downloaded via composer and have moved it into my web environment as it's own directory /adwords/. You mentioned that I can combine my Google Analytics Reporting API with this directory. Do you know if any files will be overwritten?

steponafish avatar May 08 '18 15:05 steponafish

Glad that you could resolve that. If you really need to copy files over, I recommend you to try installing both libraries on your local machine first via Composer. It will take care of everything for you. In case two libraries share some dependencies, they'll just use the same set of code.

Only when there are some conflicts, e.g., the two libraries use the same dependency but different versions, you will get error messages during running Composer. At that time, you need to fix them case by case.

I'm going to close this as the main issue is already resolved.

fiboknacky avatar May 08 '18 15:05 fiboknacky

Fatal error: Interface 'Google\AdsApi\Common\AdsBuilder' not found in /storage/ssd1/493/4996493/public_html/googleads-php-lib-master/googleads-php-lib-master/src/OAuth2TokenBuilder.php on line 29

My Ads Google/AdsApi/Common Not found how can i set own path in qauthbuilder2 file please let me know

Liquintel avatar Jul 15 '19 11:07 Liquintel