Api AdWords login in PHP (Codeigniter) without auth.ini

I am developing an application in php with codeigniter that needs to connect to Adwords and I have many questions ...

First of all, I have a test account and I don’t know if I’m connecting correctly, because I don’t know what I need to specify as DeveloperToken, clientId and defaultServer. Which one is correct?

$username = " my_email@gmail.com "; $password = "my_password"; //Developer Token options $developerToken_1 = "E2SGs1l7gEWWdCfeYSO4oA"; //It not my real token.. $developerToken_2 = " my_email@gmail.com ++USD"; $user = new AdWordsUser(null, $username, $password, $developerToken); //Default Servers //Option 1 $user->SetDefaultServer("https://adwords.google.com/"); //Option 2 $user->SetDefaultServer("https://adwords-sandbox.google.com"); //Option 3 $user->SetDefaultServer("https://sandbox.google.com"); //Client ID //Option 1 $user->SetClientId(' client_id_1+my_email@gmail.com '); //Option 2 $user->SetClientId('1234567890'); 

I think I need to use adwords v201306 version

 $campaignService = $user->GetService('CampaignService', 'v201306'); 

If I use https://adwords.google.com/ "as a Server, I get:

 Uncaught exception 'OAuth2Exception' with message '{ "error" : "invalid_client" }' 

With other servers, I get:

 A PHP Error was encountered Severity: Warning Message: SoapClient::SoapClient(https://sandbox.google.com/api/adwords/cm/v201306/CampaignService?wsdl): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found Filename: Lib/AdsSoapClient.php 

or

 A PHP Error was encountered Severity: Warning Message: SoapClient::SoapClient(https://adwords-sandbox.google.com/api/adwords/cm/v201306/CampaignService?wsdl): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found Filename: Lib/AdsSoapClient.php 

What should I do? I read a lot in too many websites and I don’t know how I can solve it.

Thanks a lot!

+4
source share
1 answer

First of all, you can find information (including the service endpoint URL) about using the Analytics API as a test account here: https://developers.google.com/adwords/api/docs/test-accounts

Secondly, readme states that the following method is used to install the service:

 $campaignService = $user->getCampaignService('v201306', 'https://adwords.google.com'); 

Finally, it seems that the parameters that you use to initialize the AdWordsUser object are slightly discharged, readme also states the following:

 $user = new AdWordsUser(NULL, NULL, NULL, $developerToken, $applicationToken, $userAgent, $clientCustomerId, NULL, NULL, $oauth2Info); 
0
source

Source: https://habr.com/ru/post/1492554/


All Articles