GithubHelp home page GithubHelp logo

googleads-php-lib's Introduction

Google Ad Manager SOAP API Client Library for PHP

This repository hosts the PHP client library for the Google Ad Manager SOAP API.

The AdWords API is sunset. You can use the new client library google-ads-php to access the new Google Ads API instead.

Minimum PHP Version Latest Stable Version Total Downloads License

IMPORTANT This client library has been updated to require PHP version 8.0 as the minimum version, as announced in #777. This means that the final version of the library that supports PHP 7 is v61.0.0, which supports Google Ad Manager API v202208, v202211, v202302, and v202305.

Google Ad Manager API v202305 is scheduled to be sunset in May 2024. Therefore, PHP 7 users have about a year to migrate to the version 8.0 or higher of PHP to avoid disruption.

Requirements and Preparation

  • System requirements and dependencies can be found in composer.json of this library. See this page for more details.
  • From version 62.0.0, this library requires the minimum PHP version to be 8.0. If you have an older version of PHP, composer command will download an older version of the googleads/googleads-php-lib library.
  • This library depends on Composer. If you don't have it installed on your computer yet, follow the installation guide for Linux/Unix/OS X or installation guide for Windows. For the rest of this guide, we're assuming that you're using Linux/Unix/OS X and have Composer installed globally, thus, your installed Composer is available on the command line as composer.

Getting started

Copy the sample Ad Manager adsapi_php.ini to your home directory and fill out the required properties before downloading the library. This library determines the home directory of your computer by using EnvironmentalVariables::getHome().

Downloading this library

There are three ways of downloading this library as described below.

Method Target Users
Using composer require Those who want to use this library as a third-party library for their projects and thus example files are not needed.
Using git clone Those who want to alter or contribute to this library (e.g., submitting a pull request) or want to run example files.
Downloading a compressed tarball Those who only want to run example files.

Note

  • If you don't have OAuth2 credentials prior to using installed application flow, you'll need examples/Auth/GetRefreshToken.php. In this case, using composer require is not an option since there are no example files downloaded with the library.
  • Our examples are meant to be run from the command line and not as a webpage. If you run them as a webpage, results may not be shown properly.

Using composer require

The steps below download this library as a third-party library for your projects. The library will be downloaded by Composer and stored under the vendor/ directory. Examples are NOT downloaded by this download method.

  1. Install the latest version using Composer.

    $ composer require googleads/googleads-php-lib
    
  2. Follow Getting started if you haven't done so.

  3. Follow Setting up your OAuth2 credentials if you haven't set up the credentials yet.

  4. You can now use the library.

Using git clone

This method is suitable for those who want to alter or contribute to this library (e.g., submitting pull requests) or wish to try our examples. All files in this repository will be downloaded.

  1. Run git clone https://github.com/googleads/googleads-php-lib.git at the command prompt.

  2. You'll get a googleads-php-lib directory. Navigate to it by running cd googleads-php-lib.

  3. Run composer install at the command prompt. This will install all dependencies needed for using the library and running examples.

  4. Follow Getting started if you haven't done so.

  5. Follow Setting up your OAuth2 credentials if you haven't set up the credentials yet.

  6. You can now use the library and run any examples you want. Try GetAllNetworks.php by executing the following command:

    $ php examples/AdManager/v202211/NetworkService/GetAllNetworks.php
    

Downloading a compressed tarball

This is suitable for those who only want to try out the Ad Manager API with this client library. The extracted directory of the tarball will contain only the examples/ directory.

  1. On the releases page, select a version you want to try. Then, under Download, select the tarball of your choice. The name of the tarball indicates which product it belongs to, for example, admanager-examples-vX.Y.Z.tar.gz.

  2. Extract your downloaded file to any location on your computer.

  3. Navigate to the extracted directory (for example, admanager-examples-vX.Y.Z).

  4. Run composer install at the command prompt. This will install all dependencies needed for using the library and running examples.

  5. Follow Getting started if you haven't done so.

  6. Follow Setting up your OAuth2 credentials if you haven't set up the credentials yet.

  7. You can now run any examples you want. Try GetAllNetworks.php by executing the following command:

    $ php examples/AdManager/v202211/NetworkService/GetAllNetworks.php
    

Setting up your OAuth2 credentials

The Ad Manager API uses OAuth2 as the authentication mechanism. Follow the appropriate guide below based on your use case:

Basic usage

The best way to learn how to use this library is to review the examples.

All our examples are meant to be run via the command line and not through a webpage.

If you're using 32-bit PHP, you'll need to change all instances of intval() to floatval() before running an example. This is due to some IDs exceeding the 32-bit PHP_INT_MAX that intval() changes your value to. In addition, when writing your own code, do not apply intval() on any attributes that are explicitly an integer.

The following snippet of code from the GetAllNetworks.php example gives you an idea of how to use this library.

$oAuth2Credential = (new OAuth2TokenBuilder())->fromFile()
    ->build();

$session = (new AdManagerSessionBuilder())->fromFile()
    ->withOAuth2Credential($oAuth2Credential)
    ->build();

$adManagerServices = new ServiceFactory();

$networkService = $adManagerServices->createNetworkService($session);

$networks = $networkService->getAllNetworks();

// Do something with the $networks.

The builder's fromFile() method looks for an adsapi_php.ini file in your home directory by default. If you want to store this file in another directory, pass the path of the file as an argument. For example:

fromFile('/config/myprops.ini')

It is highly recommended that you use an adsapi_php.ini file. However, if you don't want to or can't use one, you can use the OAuth2 token and ads session builders instead to set the same information. See the builders for details:

WSDL objects with names that are reserved PHP keywords

Some WSDL enum values have names that are reserved PHP keywords and need to be modified when used as PHP constant names. For example, AND and DEFAULT are generated as AND_VALUE and DEFAULT_VALUE.

Logging

This library conforms to PSR-3 for logging and provides the following loggers for Ad Manager:

  • SOAP logger
  • Report downloader logger

In general, each logger logs a summary and debug message for events (e.g., a SOAP API call). The level at which messages are logged depends on whether the event succeeded.

Log message \ Event status Success Failure
One-line summary INFO WARNING
Debug message (e.g., SOAP payload) DEBUG NOTICE

Configuring logging

By default, each of the library loggers logs to STDERR on a separate channel using a Monolog StreamHandler.

You can configure some options for these default loggers in the adsapi_php.ini file:

[LOGGING]
; Optional logging settings.
soapLogFilePath = "path/to/your/soap.log"
soapLogLevel = "NOTICE"

If you need to further customize logging, you can specify your own logger entirely by providing a logger that implements LoggerInterface in the Ad Manager session builder:

$session = (new AdManagerSessionBuilder())
    ...
    ->withSoapLogger(new MyCustomSoapLogger())
    ->withReportDownloaderLogger(new MyCustomReportDownloaderLogger())
    ->build();

Utilities

We provide some utilities in this client library for helping you use features in the Ad Manager API more conveniently.

Reporting

When downloading reports, you can set additional stream context options using the stream_context key to suit your needs (e.g., increasing the timeout as shown below). See also Guzzle FAQ for details.

$options = [
    'stream_context' => [
        'http' => ['timeout' => 120]
    ]
];
$requestOptionsFactory = new RequestOptionsFactory($session, $options);
$reportDownloader = new ReportDownloader($session, $requestOptionsFactory);

SSL CA files

PHP automatically sets verify_peer to true and will do its best to find the most appropriate CA bundle on your system by default. However, not all systems have a known CA bundle on disk (e.g. Windows). This library tries to locate CA bundles on your system by using Guzzle default_ca_bundle().

If this library can't find a CA bundle on your system, you'll get an error message similar to this:

cURL error 60: SSL certificate problem: unable to get local issuer certificate.

CA file issues can also cause an error like this:

Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL:
Couldn't load from
'https://ads.google.com/apis/ads/publisher/v202211/ActivityService?wsdl' :
failed to load external entity
"https://ads.google.com/apis/ads/publisher/v202211/ActivityService?wsdl

To remedy, see Steps for troubleshooting CA file issues.

Documentation

PHPDoc for this library can be found in the gh-pages branch of this repository. You can view the Ad Manager API site here.

General Ad Manager API documentation can be found on our Google Developers site.

Coding Style

We use PSR-2 as a coding style standard. Assuming that you're at the root directory of your project, to check for coding style violations, run

vendor/bin/phpcs src --standard=phpcs_ruleset.xml -np

To automatically fix (fixable) coding style violations, run

vendor/bin/phpcbf src --standard=phpcs_ruleset.xml

Getting support

For client library specific bug reports, feature requests, and patches, create an issue on the issue tracker.

For general Ad Manager API questions, bug reports, or feature requests, post to the Ad Manager API Forum.

Announcements and updates

For general Ad Manager API and client library updates and news, you can follow the Sunset Announcements mailing list and rely on the deprecation schedule.

googleads-php-lib's People

Contributors

api-vtsao avatar c960657 avatar carusogabriel avatar dependabot[bot] avatar djrosenbaum avatar dklimkin avatar edujugon avatar fiboknacky avatar gitazem avatar iulyanp avatar jclee100 avatar joneastman avatar jrdnrc avatar knobel-dk avatar matthewnessworthy avatar mikeaag avatar nosnickid avatar pierrickvoulet avatar razvanbalosin avatar saturnism avatar sgiehl avatar shakaran avatar signpostmarv avatar steerfox avatar thangduo avatar tobias-trozowski avatar v-noskov avatar vikash avatar vtsao avatar yozaz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

googleads-php-lib's Issues

CANNOT_ATTACH_BIDDING_STRATEGY_TO_CAMPAIGN when enhancedCpcEnabled = TRUE

Hi there,

I am having issues creating the campaign, below you can see a snippet of my code:

$biddingStrategyConfiguration = new BiddingStrategyConfiguration();
$biddingStrategyConfiguration->biddingStrategyType = 'MANUAL_CPC';

$biddingScheme = new ManualCpcBiddingScheme();
$biddingScheme->enhancedCpcEnabled = TRUE;
$biddingStrategyConfiguration->biddingScheme = $biddingScheme;          

the issue is with enhancedCpcEnabled property, if it is set to TRUE the API returns the following error:

BiddingErrors.CANNOT_ATTACH_BIDDING_STRATEGY_TO_CAMPAIGN

any ideas?

path error in clone

In the Github Rep the library is under src/ for the examples it needs to be lib/.

GetRefreshToken.php generating incorrect client_id in URL

In the Google API Console, I have created a new Installed Application. The client ID is (obfuscated):

54xxxxxxxxx62-n5238beunu5g6qvbxxxxxxxxxxxxxxxxx.apps.googleusercontent.com

In my auth.ini I have filled out developerToken (approved), userAgent, client_id and client_secret. When I run GetRefreshToken.php I get:

# php GetRefreshToken.php 
Log in to your AdWords account and open the following URL:
https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=54xxxxxxxxx62-t9uet6fpdq7c1j0ml93bfksm5ga36ed8.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=https%3A%2F%2Fadwords.google.com%2Fapi%2Fadwords%2F&access_type=offline

After approving the token enter the authorization code here:

Notice the client_id in the URL is NOT my client ID. The first dozen or so character is correct. But after that its totally different. When I paste in this URL (while logged into my Adwords account) I get this screen:

vcilaxi

At first I assumed maybe the client_id in the URL was some hashed value or something so I didn't think anything of it. But after not being able to figure out a reason for why I was getting this error, my friend suggested changing the URL to my correct client_id. And presto... that worked. I sent me to the page that says:

This app would like to: Manage your AdWords campaigns

I accept this and now it gives me my Refresh Token.

So what is going on here? Is this a bug? Am I misunderstanding something? I could not find the above (wrong) client_id hardcoded anywhere in the PHP library so I'm not sure where it's coming from.

Can't use method return value in write context -> DfpSoapClient.php

"PHP Fatal error: Can't use method return value in write context in /var/www/xxxxxxxxxxx/releases/20140707111201/vendor/googleads/googleads-php-lib/src/Google/Api/Ads/Dfp/Lib/DfpSoapClient.php on line 67"

i can easily correct this but since we are using composer to install the packages after a deploy this starts to get a mess.

is this a known bug?
how to fix this?

empty function use in DfpSoapClient.php compatible only with PHP >= 5.5

Hi,

in this file https://github.com/googleads/googleads-php-lib/blob/master/src/Google/Api/Ads/Dfp/Lib/DfpSoapClient.php at line 67, there is a function call (empty) compatible only with PHP versions >= 5.5.
Taking a look at PHP empty function doc page:

Prior to PHP 5.5, empty() only supports variables; anything else will result in a parse error. In other words, the following will not work: empty(trim($name)). Instead, use trim($name) == false.

Can you change it please?

Regards

Example for -> AdvancedOperations / AddCall.php

Don't suppose there is anything in the pipeline to add some example documentation on adding Call Extensions to an AdGroup?

Much like the example of adding AdvancedOperations/AddSitelinks.php

Thanks, James

Unmarshalling Error: cvc-type.2 - v201402

I apologize for bringing up an issue that was marked closed, but I'm running into the same error, and changing $addXsiTypes to true does not change the error message. I've already tried the suggestions in issue #3, but none of them have any effect on the error that I'm receiving. The code I'm running:

    // Create new campaign structure.
    $campaign = new Campaign();
    $campaign->name = 'Campaign #' . time();
    $campaign->status = 'ACTIVE';
    $campaign->advertisingChannelType = 'SEARCH'; 
    $campaign->biddingStrategyConfiguration = new BiddingStrategyConfiguration();
    $campaign->biddingStrategyConfiguration->biddingStrategyType = 'MANUAL_CPC';
    $campaign->budget = new Budget('1', 'default budget', 'DAILY', new Money(10000), 'STANDARD');
    $campaign->settings = new Setting('', '', 'TRUE');
    $operation = new CampaignOperation();
    $operation->operand = $campaign;
    $operation->operator = 'ADD';
    $operations[] = $operation;

    // Add campaign.
    $campaignReturnValue = $campaignService->mutate($operations);

Unmarshalling Error

I'm getting this error:

Fatal error: Uncaught SoapFault exception: [soap:Client] Unmarshalling Error: cvc-type.2: The type definition cannot be abstract for element ns1:searchParameters. in src/Google/Api/Ads/Common/Lib/AdsSoapClient.php:200

OS: Linux (Debian)
PHP: 5.2.6-1+lenny16
libxml: 2.6.32
API: v201302
Library: 4.2.1
Apr 2, 2013 Delete comment Project Member #1 api.pmatthews
Hi Davis,

It seems likely that you're getting this issue as $addXsiTypes is set to false, in the AdsSoapClient.php:

https://code.google.com/p/google-api-adwords-php/source/browse/src/Google/Api/Ads/Common/Lib/AdsSoapClient.php

Could you confirm that you no longer see errors if you set $addXsiType to true. To implement this, simply add the following line, at line 404:
$addXsiTypes = TRUE;

Cheers,

  • Paul, AdWords API Team.
    Status: MoreInfoNeeded
    Apr 3, 2013 Delete comment #2 couponchiefs
    I was seeing the same error (Unmarshalling Error: cvc-type.2).

OS: Linux
PHP 5.2.6
Library: 4.2.1
API: v201302

I can confirm that setting $addXsiType to true in AdsSoapClient fixes the issues. Previously the xsi types were not getting added to the XML. Once they were added, everything worked fine.
Apr 3, 2013 Delete comment #3 couponchiefs
Unfortunately, when I manually set "$addXsiTypes = TRUE;", while some of the previous failed API calls now work, it now brings back the previous error that was supposed to be fixed with this release:
"Unmarshalling Error: cvc-elt.4.2: Cannot resolve 'Selector' to a type definition for element 'ns1:serviceSelector'."
For example, this error now shows up when running the GetKeywords script.

OS: Linux
PHP 5.2.6
Library: 4.2.1
API: v201302

Apr 4, 2013 Delete comment #4 davis.fridenvalds
If I set $addXsiType to TRUE as Paul suggested, I get another error:

Fatal error: Uncaught SoapFault exception: [soap:Client] Unmarshalling Error: cvc-elt.4.2: Cannot resolve 'Paging' to a type definition for element 'ns1:paging'.

OS: Linux (Debian)
PHP: 5.2.6-1+lenny16
libxml: 2.6.32
API: v201302
Library: 4.2.1
Apr 4, 2013 Delete comment Project Member #5 api.pmatthews
Thanks for the additional info there Davis.

Can you tell me, what was the last working version of the API for you? And does it still work?

Cheers,

Paul.
Apr 4, 2013 Delete comment #6 davis.fridenvalds
The last working API version was v201206.
Apr 11, 2013 Delete comment #8 velimira
aving the same issue with
PHP Version 5.2.6-1+lenny10
libxml: 2.6.32
API: v201302
adx_api_php_lib_4.2.2

v201209 was working fine
Apr 11, 2013 Delete comment #9 davis.fridenvalds
We couldn't wait any longer and upgraded our PHP to 5.3.3-7+squeeze15 and now it is working fine.
Apr 11, 2013 Delete comment #10 kmhoggatt
The workaround I found for this issue is this:

  1. Set "$addXsiTypes = TRUE;" on AdsSoapClient.php line 404.
  2. Update all of the getXsiTypeName() functions in each of the classes defined in /Util/ReportUtils.php to return a blank string. For example, in the Paging class definition, modify the function getXsiTypeName() to 'return "";' instead of 'return "Paging";'. Do the same for Selector class, Predicate class, etc.

After doing this, lib version 4.2.2 works fine with PHP 5.2.6 and v201302.
Apr 12, 2013 Delete comment #11 velimira
Thanks, this worked
Jul 22, 2013 Delete comment #12 steve962
I ran into the same exact issue with lib version 4.4.0. The solution presented in comment #10, editing the ReportUtils.php module to change all the getXsiTypeName() calls to return empty strings worked for me, even though it meant changing the library, something I really hate to do. (But was necessary to get us updated so we were running again.)

PHP Version 5.2.4-2ubuntu5.17
libxml version: 2.6.31
API: v201306
adwords_api_php_4.4.0

We were upgrading from API v201209 using lib 3.2.1, which worked fine.

Sep 26, 2013 Delete comment Project Member #13 api.pmatthews
We'll look into making this value configurable from the settings.ini

Regards,

  • Paul, AdWords API Team.

Short description of the bug

Which version of the library are you using? adwords_api_php_4.5.1

Which version of PHP are you using? 5.2.4-2ubuntu5.26

What steps will reproduce the problem?
Go to /adwords_api_php_4.5.1/examples/AdWords/v201306/Optimization/GetKeywordIdeas.php

What is the expected output? What do you see instead?
I expect to see an example of keywords ideas (from demo).

Instead I see
Warning: Error parsing {path}/adwords_api_php_4.5.1/src/Google/Api/Ads/AdWords/Lib/api.properties on line 15 in {path}/adwords_api_php_4.5.1/src/Google/Api/Ads/Common/Util/ApiPropertiesUtils.php on line 34

Notice: Undefined index: api.versions in {path}/adwords_api_php_4.5.1/src/Google/Api/Ads/AdWords/Lib/AdWordsUser.php on line 120

Notice: Undefined index: api.server in {path}/adwords_api_php_4.5.1/src/Google/Api/Ads/AdWords/Lib/AdWordsUser.php on line 122
An error has occurred: Unmarshalling Error: cvc-elt.4.2: Cannot resolve 'Paging' to a type definition for element 'ns1:paging'.

Please provide any additional information below.

Upon investigation I can see that the ApiPropertiesUtils class is trying to parse_ini_file the api.properties file, but doesn't like the JSON lines.
I have tried putting quotes around, and this does get rid of all the errors except the last one.
An error has occurred: Unmarshalling Error: cvc-elt.4.2: Cannot resolve 'Paging' to a type definition for element 'ns1:paging'.

Aug 5, 2013 Delete comment Project Member #1 api.pmatthews
Cheers for reporting this nick.

I'll look into adding a permanent solution.

As for the cvc-elt issue, I believe that's unrelated, can you file this as another bug?

Regards,

  • Paul, AdWords API Team.

Problem with Oauth2 in v5.5.1.

After update to v5.5.1. my old script throws exceptions. It in two places different exceptions:
First:

$user =  new \AdWordsUser(\Yii::$app->params['google.services.settings']['authenticationIniPath'],     $email = NULL, $password = NULL, $developerToken = NULL, $applicationToken = NULL,            $userAgent = NULL, 'XXXX-XXXXX-XXXX-XXXX', $settingsIniPath = NULL,  $authToken = NULL, $oauthInfo = NULL);
$adGroupService = $user->GetService('AdGroupService', 'v201402');

Exception:

Validation failed for [client_id] with value []: client_id is required.
 /home/www-data/www/adwyii/vendor/googleads/googleads-php-lib/src/Google/Api/Ads/Common/Lib/AdsUser.php at line 522
2. in /home/www-data/www/adwyii/vendor/googleads/googleads-php-lib/src/Google/Api/Ads/AdWords/Lib/AdWordsUser.php โ€“ AdsUser::ValidateOAuth2Info() at line 355
3. in /home/www-data/www/adwyii/vendor/googleads/googleads-php-lib/src/Google/Api/Ads/AdWords/Lib/AdWordsUser.php โ€“ AdWordsUser::ValidateUser() at line 222
4. in /home/www-data/www/adwyii/frontend/modules/keywordsgeneration/controllers/DefaultController.php โ€“ AdWordsUser::GetService('AdGroupService', 'v201402') at line 45
5. frontend\modules\keywordsgeneration\controllers\DefaultController::actionCreate()
6. in /home/www-data/www/adwyii/vendor/yiisoft/yii2/base/InlineAction.php โ€“ call_user_func_array([frontend\modules\keywordsgeneration\controllers\DefaultController, 'actionCreate'], []) at line 55
7. in /home/www-data/www/adwyii/vendor/yiisoft/yii2/base/Controller.php โ€“ yii\base\InlineAction::runWithParams(['r' => 'keywordsgeneration/default/creat...']) at line 150
8. in /home/www-data/www/adwyii/vendor/yiisoft/yii2/base/Module.php โ€“ yii\base\Controller::runAction('create', ['r' => 'keywordsgeneration/default/creat...']) at line 462
9. in /home/www-data/www/adwyii/vendor/yiisoft/yii2/web/Application.php โ€“ yii\base\Module::runAction('keywordsgeneration/default/creat...', ['r' => 'keywordsgeneration/default/creat...']) at line 83
10. in /home/www-data/www/adwyii/vendor/yiisoft/yii2/base/Application.php โ€“ yii\web\Application::handleRequest(yii\web\Request) at line 371
11. in /home/www-data/www/adwyii/frontend/web/index.php โ€“ yii\base\Application::run()

Second:

 $user =  new \AdWordsUser(\Yii::$app->params['google.services.settings']['authenticationIniPath'], $email = NULL,
                $password = NULL, $developerToken = NULL, $applicationToken = NULL,
                $userAgent = NULL, $clientId = 'XXX-XXX-XXX', $settingsIniPath = NULL,
                $authToken = NULL, $oauthInfo = NULL);

$reportQuery = 'SELECT Ctr,AdGroupId, AverageCpc, CostPerConversion, ConversionRate,Cost,Impressions, CampaignName, AdGroupName, AccountDescriptiveName '
                . 'FROM ADGROUP_PERFORMANCE_REPORT '
                . 'WHERE Status= "ENABLED" AND AdNetworkType1=SEARCH AND CampaignId=1  DURING 20050101,' . date('Ymd');
 \ReportUtils::DownloadReportWithAwql($reportQuery, $csvFileForGroup, $user, 'CSV', $options);

Exception:

PHP Recoverable Error 'yii\base\ErrorException' with message 'Argument 1 passed to OAuth2Handler::GetOrRefreshAccessToken() must be of the type array, string given, called in /home/www-data/www/adwyii/vendor/googleads/googleads-php-lib/src/Google/Api/Ads/AdWords/Util/ReportUtils.php on line 313 and defined'

When I use revision with commit hash: 52123a0 it works fine

WSDLInterpreter change service class name

In file src/Google/Api/Ads/AdWords/Lib/api.properties is option "wsdl2php.enablePseudoNamespaces". It includes description:

"If enabled, class names (but not service names) will be prefixed with the package name. Ex) GoogleApiAdsAdWords_Campaign"

but if I run Phing with wsdl2php.enablePseudoNamespaces=True, I see that service classes names changes too. For example CampaignService changes to GoogleApiAdsAdWords_CampaignService. In previous version of this lib (WSDLInterpreter v 4.6.1) service classes names didn't changes.

Undefined property: stdClass::$ApiError CodeError:8

Sometimes, I catch exception: "Undefined property: stdClass::$ApiError" CodeError:8 I get report from google adwords. My script is running every day and doing query to google(with pauses, course). But sometimes I catch this exception: "Undefined property: stdClass::$ApiError". When I repeat query, I didn't get it. In first, I think it error with google server, and I wrap ReportUtils::DownloadReportWithAwql. If I catch this exception I sleep for 15-30 seconds and try again. I repeat it 5 times and if catch same exception, throw it.

Controller.php

$user = 'my user';
$reportQuery = 'SELECT Id, AverageCpc, Cost, Clicks, AdGroupId, KeywordText,
                Conversions, Impressions  FROM KEYWORDS_PERFORMANCE_REPORT WHERE
                Status= "ACTIVE"  AND  Impressions>0 AND CampaignId=123456789  DURING
                20140822,20140822';
$tmpCsv = 'foobar.csv';
ReportUtils::DownloadReportWithAwql($reportQuery, $tmpCsv, $user, 'CSV', ['version' =>'v201402']]);

ReportUtils.php (my wrap)

 public static function DownloadReportWithAwql($reportQuery, $path = NULL,
                                                  \AdWordsUser $user, $reportFormat, array $options = NULL) {
        self::init();

        $lastIteration = 0;

        do {
            try{
                $throwException = true;
                \ReportUtils::DownloadReportWithAwql($reportQuery, $path,  $user, $reportFormat, $options);

            } catch(\Exception $e){

                //if errror 5xx or 0 or 8, waiting and trying else
                /* These exceptions are thrown with a random order. I can not keep track of them and support google says nothing.
                 * 5xx - error on google server.
                 * 0 - couldn't connect to host
                 * 8 - this exception: Undefined property: stdClass::$ApiError
                 *
                 * */
                if (($e->getCode() >= 500 && $e->getCode() < 600) || $e->getCode() == 0 || $e->getCode() == 8) {
                    $lastIteration++;

                    if ($lastIteration < ReportUtils::ATTEMPS) {
                        $throwException = false;
                        \Yii::info($reportQuery,self::CATEGORY);
                        sleep(mt_rand(15, 45));
                    }
                }

                if ($throwException) {
                    $message = "Error with download report. Query:{$reportQuery} Error:{$e->getMessage()} CodeError:{$e->getCode()}";
                    throw new \yii\console\Exception($message);
                }


            }
        } while($throwException === false);

        return true;
    }

What`s problem?

Offline conversions: $conversionTime returning INVALID_FIELD_VALUES_IN_DATE_TIME

I was uploading offline conversions few days ago and I was passing the date as "20140306 143017" (just an example) just by doing $conversionTime->format('Ymd His'), according to the docs, time zone is optional, if it's not passed then it will set it as the one configured in my MMC account.

It was working fine until few days ago, I started getting DateError.INVALID_FIELD_VALUES_IN_DATE_TIME (I didn't change anything in my code) and looking at the documentation I see the date formatting is correct.
https://developers.google.com/adwords/api/docs/reference/v201309/ConversionTrackerService#DateError

So I included the time zone parameter like this $conversionTime->format('Ymd His P') and it seems to work just fine. I was wondering if something change in the API side that made it required. If it is, where should I address this documentation change to?

Thank you.

Improper sanitization of responses

Testing out one of the examples with my DFP data, GetAllCustomTargetingKeysAndValuesExample.php from version v201311, it seems that the soap client is failing to import the XML received from Google for a single custom Key's values. In my case, all of my keys return their value fine, except one (I discovered through trial an error with LIMIT and OFFSET).

The offending Key / Value query throws the following:

PHP Fatal error: Uncaught SoapFault exception: [Client] looks like we got no XML document in /Sites/dfp-playground/htdocs/googleads-php-lib/src/Google/Api/Ads/Common/Lib/AdsSoapClient.php:216

Here's the stack trace:

PHP Notice:  Failed to load response into DOM: DOMDocument::loadXML(): PCDATA invalid Char value 31 in Entity, line: 1 in /Sites/dfp-playground/htdocs/googleads-php-lib/src/Google/Api/Ads/Common/Lib/AdsSoapClient.php on line 248
PHP Stack trace:
PHP   1. {main}() /Sites/dfp-playground/htdocs/googleads-php-lib/examples/Dfp/v201311/CustomTargetingService/GetAllCustomTargetingKeysAndValuesExample.php:0
PHP   2. CustomTargetingService->getCustomTargetingValuesByStatement() /Sites/dfp-playground/htdocs/googleads-php-lib/examples/Dfp/v201311/CustomTargetingService/GetAllCustomTargetingKeysAndValuesExample.php:105
PHP   3. AdsSoapClient->__soapCall() /Sites/dfp-playground/htdocs/googleads-php-lib/src/Google/Api/Ads/Dfp/v201311/CustomTargetingService.php:3530
PHP   4. AdsSoapClient->ProcessResponse() /Sites/dfp-playground/htdocs/googleads-php-lib/src/Google/Api/Ads/Common/Lib/AdsSoapClient.php:222
PHP   5. trigger_error() /Sites/dfp-playground/htdocs/googleads-php-lib/src/Google/Api/Ads/Common/Lib/AdsSoapClient.php:248
PHP Notice:  Failed to load response into DOM: DOMDocument::loadXML(): PCDATA invalid Char value 31 in Entity, line: 1 in /Sites/dfp-playground/htdocs/googleads-php-lib/src/Google/Api/Ads/Common/Lib/AdsSoapClient.php on line 355
PHP Stack trace:
PHP   1. {main}() /Sites/dfp-playground/htdocs/googleads-php-lib/examples/Dfp/v201311/CustomTargetingService/GetAllCustomTargetingKeysAndValuesExample.php:0
PHP   2. CustomTargetingService->getCustomTargetingValuesByStatement() /Sites/dfp-playground/htdocs/googleads-php-lib/examples/Dfp/v201311/CustomTargetingService/GetAllCustomTargetingKeysAndValuesExample.php:105
PHP   3. AdsSoapClient->__soapCall() /Sites/dfp-playground/htdocs/googleads-php-lib/src/Google/Api/Ads/Dfp/v201311/CustomTargetingService.php:3530
PHP   4. AdsSoapClient->ProcessResponse() /Sites/dfp-playground/htdocs/googleads-php-lib/src/Google/Api/Ads/Common/Lib/AdsSoapClient.php:222
PHP   5. AdsSoapClient->LogRequestInfo() /Sites/dfp-playground/htdocs/googleads-php-lib/src/Google/Api/Ads/Common/Lib/AdsSoapClient.php:260
PHP   6. DfpSoapClient->GenerateRequestInfoMessage() /Sites/dfp-playground/htdocs/googleads-php-lib/src/Google/Api/Ads/Common/Lib/AdsSoapClient.php:292
PHP   7. AdsSoapClient->GetLastResponseTime() /Sites/dfp-playground/htdocs/googleads-php-lib/src/Google/Api/Ads/Dfp/Lib/DfpSoapClient.php:130
PHP   8. trigger_error() /Sites/dfp-playground/htdocs/googleads-php-lib/src/Google/Api/Ads/Common/Lib/AdsSoapClient.php:355
PHP Notice:  Failed to load response into DOM: DOMDocument::loadXML(): PCDATA invalid Char value 31 in Entity, line: 1 in /Sites/dfp-playground/htdocs/googleads-php-lib/src/Google/Api/Ads/Common/Lib/AdsSoapClient.php on line 373
PHP Stack trace:
PHP   1. {main}() /Sites/dfp-playground/htdocs/googleads-php-lib/examples/Dfp/v201311/CustomTargetingService/GetAllCustomTargetingKeysAndValuesExample.php:0
PHP   2. CustomTargetingService->getCustomTargetingValuesByStatement() /Sites/dfp-playground/htdocs/googleads-php-lib/examples/Dfp/v201311/CustomTargetingService/GetAllCustomTargetingKeysAndValuesExample.php:105
PHP   3. AdsSoapClient->__soapCall() /Sites/dfp-playground/htdocs/googleads-php-lib/src/Google/Api/Ads/Dfp/v201311/CustomTargetingService.php:3530
PHP   4. AdsSoapClient->ProcessResponse() /Sites/dfp-playground/htdocs/googleads-php-lib/src/Google/Api/Ads/Common/Lib/AdsSoapClient.php:222
PHP   5. AdsSoapClient->LogRequestInfo() /Sites/dfp-playground/htdocs/googleads-php-lib/src/Google/Api/Ads/Common/Lib/AdsSoapClient.php:260
PHP   6. DfpSoapClient->GenerateRequestInfoMessage() /Sites/dfp-playground/htdocs/googleads-php-lib/src/Google/Api/Ads/Common/Lib/AdsSoapClient.php:292
PHP   7. AdsSoapClient->GetLastRequestId() /Sites/dfp-playground/htdocs/googleads-php-lib/src/Google/Api/Ads/Dfp/Lib/DfpSoapClient.php:131
PHP   8. trigger_error() /Sites/dfp-playground/htdocs/googleads-php-lib/src/Google/Api/Ads/Common/Lib/AdsSoapClient.php:373
PHP Fatal error:  Uncaught SoapFault exception: [Client] looks like we got no XML document in /Sites/dfp-playground/htdocs/googleads-php-lib/src/Google/Api/Ads/Common/Lib/AdsSoapClient.php:216
Stack trace:
#0 /Sites/dfp-playground/htdocs/googleads-php-lib/src/Google/Api/Ads/Common/Lib/AdsSoapClient.php(216): SoapClient->__soapCall('getCustomTarget...', Array, NULL, Array, Array)
#1 /Sites/dfp-playground/htdocs/googleads-php-lib/src/Google/Api/Ads/Dfp/v201311/CustomTargetingService.php(3530): AdsSoapClient->__soapCall('getCustomTarget...', Array)
#2 /Sites/dfp-playground/htdocs/googleads-php-lib/examples/Dfp/v201311/CustomTargetingService/GetAllCustomTargetingKeysAndValuesExample.php(105): CustomTargetingService->getCustomTargetingValuesByStatement(Object(Statement))
#3 {main}
  thrown in /Sites/dfp-playground/htdocs/googleads-php-lib/src/Google/Api/Ads/Common/Lib/AdsSoapClient.php on line 216

It looks like the library is receiving an unexpected Entity from the API, so the problem could be with the API itself, but I'll leave that up to you.

curl CURLOPT_FOLLOWLOCATION not working with open_basedir set

What steps will reproduce the problem?
1.Set open_basedir in php.ini on the server
2.Try to run code
$networkService = $user->GetService('NetworkService', API_VERSION));
3.

What is the expected output? What do you see instead?
I should get NETWORK SERVICE, instead i get an error:
"curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set"

What version of the product are you using? On what operating system?
I used many version.
Windows 7.

Please provide any additional information below.
Maybe you could try to take a look at this article and try to find a workaround for this:
http://webhostbug.com/php-curl-curlopt-followlocation-and-open_basedir-or-safe-mode/

Api support for allowing developers to parse the xml response

Currently DfpSoapClient processes the soap xml response using DOMDocument.
Developers need a way to parse the soap xml response themselves for performance
(DOMDocument parses entire xml) and for getting partial objects.

I prefer to use XMLReader as I only need some of the xml tags and not the entire object.

`Google_Api_Ads_AdWords_Lib_AdWordsSoapClient` with wsdl2php.enablePseudoNamespaces=True

Related to #45.

I've run the phing task (with the modification described here), I am able to generate a pseudo namespaced library. However, when I go to use it, I receive:

Fatal error: Class 'Google_Api_Ads_AdWords_Lib_AdWordsSoapClient' not found in /[...]/Google/Api/Ads/AdWords/v201402/ManagedCustomerService.php on line 3958

In ManagedCustomerService.php, I see:

class Google_Api_Ads_AdWords_v201402_ManagedCustomerService extends Google_Api_Ads_AdWords_Lib_AdWordsSoapClient {

However, in AdWordsSoapClient.php, there is only:

class AdWordsSoapClient extends AdsSoapClient {

I believe the build process for wsdl2php.enablePseudoNamespaces=True libraries is broken, or isn't sufficiently documented as to how to do it correctly.

How to install this lib without using global PHP paths?

According to the README.md in the lib folder:

Copy the contents of this directory to the location of your PHP source files that is on your PHP include path.

Okay so, I have to install this lib in a global path location so that PHP can load it from anywhere. How do I install and use this library while installing the lib only local to my specific project I'm using it for?

Installing a library globally on the server level just for one PHP project to use it is generally poor practice imo.

StatementBuilder->Limit not working in v20148

Can't figure out why this isn't working. Ideas?

$service = $user->GetService('ReportService', 'v201408');
$statementBuilder = new \StatementBuilder();
$statementBuilder->Limit(10);

$reportQuery = new \ReportQuery();
$reportQuery->dimensions = array(
    'TARGETING', 'AD_UNIT_ID', 'AD_UNIT_NAME'
);

$reportQuery->columns = array(
    'AD_SERVER_IMPRESSIONS',
    'AD_SERVER_CLICKS',
    'TOTAL_LINE_ITEM_LEVEL_IMPRESSIONS'
);

$reportQuery->statement = $statementBuilder->ToStatement();
$reportQuery->dateRangeType = 'YESTERDAY';

$reportJob = new \ReportJob();
$reportJob->reportQuery = $reportQuery;
$reportJob = $service->runReportJob($reportJob);

Results in:

[PublisherQueryLanguageContextError.UNEXECUTABLE @ 'LIMIT' is unsupported.]
/.../library/Google/Api/Ads/Common/Lib/AdsSoapClient.php line 238

[AdWords] Using an existing OAuth1 token

While working to update for the v201402 release, I noticed that this library removed all support for using OAuth1 tokens. I can see that it's cited as being removed in 4.3. I have 5,000+ user tokens that are still being used today that have not yet been upgraded to OAuth2 through a re-authroization process. Is there a workaround with the library to use these (at minimum, for the adhoc reporting functionality)?

History

  • 8/2011 - Application built with OAuth1 (not ClientLogin)
  • 5/2012 - New authentication system for other Google properties introduced with OAuth2, application modified to work with either (new users were prompted to create OAuth2 tokens)
  • 6/2014 - One month ahead of sunset for v201309, need to update library to continue to support tokens that have not yet been re-authorized.

From my perspective, it looks like we may be stuck in a no-man's land as we never used ClientLogin (where most of the upgrade energy is being focused).

So my question really boils down to:

  • Is using an OAuth1 token even possible with the new API endpoints?
  • If it is possible, what modifications can be done to the client library to fascilitate using them in the interim?
  • Will OAuth1 have a sunset schedule like ClientLogin did?

Support composer autoloader

Adding composer.json is a step in the right direction, unfortunately it doesn't work with the composer autoloader.
The following code will not work unless I include the file manually:

$user = new \AdWordsUser(/*parameters*/);

Please see https://github.com/colinmutter/google-api-adwords-php which has successfully made the adwords SDK for PHP work with composer and the autoloader. Unfortunately the package is not up to date with the latest version of the code.

defaultVersion visibility issue

Hi!,

I'm using 5.5.2, which has v201402, v201406 and v201409.

Considering the following constructor:

new AdWordsUser($authFile, null, null, null, $ccid, $settingsFile)

And my $settingsFile looks like this:

....

[SERVER]
DEFAULT_VERSION = "v201406"
DEFAULT_SERVER = "https://adwords.google.com"

....

What do you expect as defaultVersion? v201406 right? Well no, AdwordsUser will never change it. See:

AdwordsUser line 113 sets the latest version as defaultVersion. On line 153, settings get parsed by the abstract parent AdsUser.php, which is supposed to parse and set the defaultVersion member.

Both AdwordsUser and AdsUser have a private defaultVersion. So that means that AdsUser can never see AdwordsUser's property, and will set "v201406" to it's own scope.

It is not a good practice to have duplicate class members, and with them being private, it's now impossible to set a version. The only possible method is giving the version argument each time getService() is called. I'd rather have my version set globally at the AdwordsUser instance.

Anyway, if you remove the defaultVersion property from AdwordsUser and set visibility to protected on AdsUser, it will work perfectly. This might also apply for libVersion, libName and defaultServer

Syntax error, unexpected '}' in some examples

Hi,
Executing the next script:

find . -iregex '.*(.php)' -exec php -l '{}' ; | grep "Parse error:"

you can see that 3 examples files has syntax errors.

Parse error: syntax error, unexpected '}', expecting T_CATCH in ./googleads-php-lib/examples/Dfp/v201403/CreativeSetService/CreateCreativeSetsExample.php on line 75
Parse error: syntax error, unexpected '}', expecting T_CATCH in ./googleads-php-lib/examples/Dfp/v201403/InventoryService/CreateMobileAdUnitExample.php on line 87
Parse error: syntax error, unexpected '}', expecting T_CATCH in ./googleads-php-lib/examples/Dfp/v201403/InventoryService/CreateVideoAdUnitExample.php on line 101

I've downloaded via composer the 5.2.2 version of googleads-php-lib and we use php 5.3.27.

Lluis

Oauth2.0 approval_prompt = force

Hello All,

I am not seeing approval_prompt option under Oauth2.0 authentication which can enable user to approve appllication request every time he logged in with google account.

For more info please see this forum question:
https://groups.google.com/forum/#!searchin/adwords-api/oauth2.0/adwords-api/GTClxukrLCE/GdO1bRsGkWkJ

No option for this under PHP Client library v201306.

Thanks,
Chirag
Jul 17, 2013 Delete comment #1 chirag.ebrandz
Hi,

Any update?
Jul 22, 2013 Delete comment Project Member #2 api.pmatthews
Hi Chirag,

Thank you for your feature request. For the a quick workaround, I suggest you edit your copy of the OAuth2Handler.php to add the following:

Edit the GetAuthorizationUrl.php function to update the $params array as follows:

$params = array_merge($params, array(
    'response_type' => 'code',
    'client_id' => $credentials['client_id'],
    'redirect_uri' => $redirectUri,
    'scope' => $this->scope,
    'access_type' => $offline ? 'offline' : 'online',
    'approval_prompt' => 'force',
));

File path:
/src/Google/Api/Ads/Common/OAuth2Handler.php

See the link below for the current version:

https://code.google.com/p/google-api-adwords-php/source/browse/src/Google/Api/Ads/Common/Util/OAuth2Handler.php#59

Regards,

  • Paul, AdWords API Team.
    Labels: -Type-Question Type-en
    Jul 22, 2013 Delete comment Project Member #3 api.pmatthews
    (No comment was entered for this change.)
    Labels: -Type-en Type-Enhancement
    Jul 23, 2013 Delete comment #4 chirag.ebrandz
    Hello Paul,

Yes, I dont wants to disturb API. So i have done this when getting to authorization Url by adding extra param.

    $offline = TRUE;
$extra_para = array('approval_prompt' => 'force');
$OAuth2Handler = $user->GetOAuth2Handler();
$authorizationUrl = $OAuth2Handler->GetAuthorizationUrl($user->GetOAuth2Info(), $redirectUri, $offline, $extra_para);

I have one more Question under enhancement.
I am not getting any user information by calling Oauth 2.0. For e.g. user email.
For this i need to add any other scope. So how i can add other scopes?

Thanks,
Chirag
Sep 26, 2013 Delete comment Project Member #5 api.pmatthews
We're looking into adding a config parameter for the approval_promt setting.

Can you explain what service you're calling that is not returning a user email?

Regards,

  • Paul, AdWords API Team.
    Status: Accepted
    Sep 26, 2013 Delete comment #6 chirag.ereportz
    Hi,

I'm trying to calling CustomerService.
CustomerService that will give me idea about customer who tryed to get data using API.
This will help a lot when user is using MCC account for authentication, and adwords account has no CompanyName / Name info.
Oct 4, 2013 Delete comment #7 chirag.ereportz
Also, I requested you to Add all beta feature to be available for all developer.

Unmarshalling Error: cvc-type.2

lib: v201402
PHP: 5.4.7

Error "Unmarshalling Error: cvc-type.2: The type definition cannot be abstract for element ns1:settings" is shown based on the following code:

$adGroup = new AdGroup();
$adGroup->campaignId = SOME_ID;
$adGroup->name = SOME_NAME;
$adGroup->status = 'ENABLED';

        $bid = new CpcBid();
        $bid->bid = new Money(1000000);
        $biddingStrategyConfiguration = new BiddingStrategyConfiguration();
        $biddingStrategyConfiguration->bids[] = $bid;
        $adGroup->biddingStrategyConfiguration = $biddingStrategyConfiguration;

          $targetingSetting = new TargetingSetting();
          $targetingSetting->details[] =
          new TargetingSettingDetail('PLACEMENT', TRUE);
          $targetingSetting->details[] =
          new TargetingSettingDetail('VERTICAL', FALSE);
          $adGroup->settings[] = $targetingSetting;

        $operation = new AdGroupOperation();
        $operation->operand = $adGroup;
        $operation->operator = 'ADD';
        $operations[] = $operation;

        $adGroupMutateResult = $adGroupService->mutate($operations);

Campaign exists and is available. This error pops up when trying to add AdGroup to campaign.

Also: setting $addXsiTypes = TRUE; in AdsSoapClient.php results in a different error message:

Unmarshalling Error: cvc-elt.4.2: Cannot resolve 'ns1:CampaignOperation' to a type definition for element 'ns1:operations'.

Any advice?

Cannot load `api.properties` file when building from source

I need to use the pseudo-namespace argument when building the library from the WSDLs. I suspect there is something that is supposed to happen with Phing to load settings from ../src/Google/Api/Ads/AdWords/Lib/api.properties that isn't happening.

The final error (after it created a bogus folder) is [PHP Error] Unable to parse classmap as JSON. [line 167 of /Users/stephen/Downloads/googleads-php-lib/build_lib/Wsdl2PhpTask.php]. I suspect this may be related to #22.

Steps to recreate:

  1. Ensure phing is installed and working correctly.
  2. Navigate to ./build_lib
  3. $ phing -verbose
  4. Observe:
Buildfile: /Users/stephen/Downloads/googleads-php-lib/build_lib/build.xml
Override ignored for user property phing.file
Override ignored for user property phing.dir
Overriding previous definition of reference to phing.file
parsing buildfile build.xml
Project base dir set to: /Users/stephen/Downloads/googleads-php-lib
Property ${project.basedir} => /Users/stephen/Downloads/googleads-php-lib
Property ${lib.product} has not been set.
Property ${lib.product} has not been set.
Property ${lib.product} has not been set.
Property ${lib.product} has not been set.
Property ${lib.product} has not been set.
Property ${lib.package} has not been set.
Property ${lib.package} has not been set.
Property ${lib.package} has not been set.
Property ${lib.package} has not been set.
Property ${lib.package} has not been set.
Property ${wsdl2php.classpath} => build_lib
  [taskdef] Task wsdl2php will be handled by class Wsdl2PhpTask
  Build sequence for target 'generate-src' is: generate-src 
Complete build sequence is: generate-src  generate-version generate-service 

adsapi_php > generate-src:

Property ${api.versions} has not been set.
Property ${api.versions} has not been set.
Property ${api.versions} has not been set.
Property ${api.versions} has not been set.
Property ${api.versions} has not been set.
  [foreach] Setting param 'version' to value '${api.versions}'
Task property (phing.tasks.system.PropertyTask) already registered, skipping
  [foreach] Calling Buildfile '/Users/stephen/Downloads/googleads-php-lib/build_lib/build.xml' with target 'generate-version'
Overriding previous definition of reference to phing.file
parsing buildfile build.xml
Overriding previous definition of reference to phing.file.adsapi_php
Overriding previous definition of reference to phing.dir.adsapi_php
Overriding previous definition of property phing.project.name
Overriding previous definition of reference to phing.project.name
Overriding previous definition of reference to project.basedir
Project base dir set to: /Users/stephen/Downloads/googleads-php-lib
Property ${project.basedir} => /Users/stephen/Downloads/googleads-php-lib
Property ${lib.product} has not been set.
Property ${lib.product} has not been set.
Property ${lib.product} has not been set.
Property ${lib.product} has not been set.
Property ${lib.product} has not been set.
Property ${lib.package} has not been set.
Property ${lib.package} has not been set.
Property ${lib.package} has not been set.
Property ${lib.package} has not been set.
Property ${lib.package} has not been set.
Property ${wsdl2php.classpath} => build_lib
  [taskdef] Task wsdl2php will be handled by class Wsdl2PhpTask
Task wsdl2php (Wsdl2PhpTask) already registered, skipping
Build sequence for target 'generate-version' is: generate-version 
Complete build sequence is: generate-version  generate-src generate-service 

adsapi_php > generate-version:

Property ${out.dir} => /Users/stephen/Downloads/googleads-php-lib/src
Property ${product} => ${lib.product}
Property ${version} => ${api.versions}
Property ${lib.product} has not been set.
Property ${api.versions} has not been set.
Property ${lib.product} has not been set.
Property ${api.versions} has not been set.
Property ${lib.product} has not been set.
Property ${api.versions} has not been set.
Property ${lib.product} has not been set.
Property ${api.versions} has not been set.
Property ${version.dir} => /Users/stephen/Downloads/googleads-php-lib/src/Google/Api/Ads/${lib.product}/${api.versions}
Property ${lib.product} has not been set.
Property ${api.versions} has not been set.
Property ${lib.product} has not been set.
Property ${api.versions} has not been set.
Property ${lib.product} has not been set.
Property ${api.versions} has not been set.
Property ${lib.product} has not been set.
Property ${api.versions} has not been set.
   [delete] Deleting /Users/stephen/Downloads/googleads-php-lib/src/Google/Api/Ads/${lib.product}/${api.versions}/
   [delete] Deleted 1 directory from /Users/stephen/Downloads/googleads-php-lib/src/Google/Api/Ads/${lib.product}/${api.versions}
Property ${version.dir} => /Users/stephen/Downloads/googleads-php-lib/src/Google/Api/Ads/${lib.product}/${api.versions}
Property ${lib.product} has not been set.
Property ${api.versions} has not been set.
Property ${lib.product} has not been set.
Property ${api.versions} has not been set.
Property ${lib.product} has not been set.
Property ${api.versions} has not been set.
Property ${lib.product} has not been set.
Property ${api.versions} has not been set.
    [mkdir] Created dir: /Users/stephen/Downloads/googleads-php-lib/src/Google/Api/Ads/${lib.product}/${api.versions}
Property ${version} => ${api.versions}
Property ${api.versions} has not been set.
Property ${api.versions} has not been set.
Property ${api.versions} has not been set.
Property ${api.versions} has not been set.
  [foreach] Setting param 'service' to value '${api.versions.${api.versions}.services}'
Task property (phing.tasks.system.PropertyTask) already registered, skipping
Overriding previous definition of reference to version
  [foreach] Calling Buildfile '/Users/stephen/Downloads/googleads-php-lib/build_lib/build.xml' with target 'generate-service'
Overriding previous definition of reference to phing.file
parsing buildfile build.xml
Overriding previous definition of reference to phing.file.adsapi_php
Overriding previous definition of reference to phing.dir.adsapi_php
Overriding previous definition of property phing.project.name
Overriding previous definition of reference to phing.project.name
Overriding previous definition of reference to project.basedir
Project base dir set to: /Users/stephen/Downloads/googleads-php-lib
Property ${project.basedir} => /Users/stephen/Downloads/googleads-php-lib
Property ${lib.product} has not been set.
Property ${lib.product} has not been set.
Property ${lib.product} has not been set.
Property ${lib.product} has not been set.
Property ${lib.product} has not been set.
Property ${lib.package} has not been set.
Property ${lib.package} has not been set.
Property ${lib.package} has not been set.
Property ${lib.package} has not been set.
Property ${lib.package} has not been set.
Property ${wsdl2php.classpath} => build_lib
  [taskdef] Task wsdl2php will be handled by class Wsdl2PhpTask
Task wsdl2php (Wsdl2PhpTask) already registered, skipping
Build sequence for target 'generate-service' is: generate-service 
Complete build sequence is: generate-service  generate-src generate-version 

adsapi_php > generate-service:

Property ${version} => ${api.versions}
Property ${service} => ${api.versions.${api.versions}.services}
Property ${api.versions} has not been set.
Property ${api.versions} has not been set.
Property ${api.versions} has not been set.
Property ${api.versions} has not been set.
Property ${api.versions} has not been set.
Property ${api.versions} has not been set.
Property ${api.versions} has not been set.
Property ${api.versions} has not been set.
Property ${product} => ${lib.product}
Property ${lib.product} has not been set.
Property ${lib.product} has not been set.
Property ${lib.product} has not been set.
Property ${lib.product} has not been set.
Property ${version} => ${api.versions}
Property ${api.versions} has not been set.
Property ${api.versions} has not been set.
Property ${api.versions} has not been set.
Property ${api.versions} has not been set.
Property ${package} => ${lib.package}
Property ${lib.package} has not been set.
Property ${lib.package} has not been set.
Property ${lib.package} has not been set.
Property ${lib.package} has not been set.
Property ${wsdl2php.enablePseudoNamespaces} has not been set.
Property ${wsdl2php.enablePseudoNamespaces} has not been set.
Property ${wsdl2php.enablePseudoNamespaces} has not been set.
Property ${wsdl2php.enablePseudoNamespaces} has not been set.
Property ${wsdl2php.enablePseudoNamespaces} has not been set.
Property ${soapClientClass} => ${lib.product}SoapClient
Property ${lib.product} has not been set.
Property ${lib.product} has not been set.
Property ${lib.product} has not been set.
Property ${lib.product} has not been set.
Property ${service.wsdl} => ${api.versions.${api.versions}.services.${api.versions.${api.versions}.services}.wsdl}
Property ${api.versions} has not been set.
Property ${api.versions} has not been set.
Property ${api.versions} has not been set.
Property ${api.versions} has not been set.
Property ${api.versions} has not been set.
Property ${api.versions} has not been set.
Property ${api.versions} has not been set.
Property ${api.versions} has not been set.
Property ${service} => ${api.versions.${api.versions}.services}
Property ${api.versions} has not been set.
Property ${api.versions} has not been set.
Property ${api.versions} has not been set.
Property ${api.versions} has not been set.
Property ${version} => ${api.versions}
Property ${api.versions} has not been set.
Property ${api.versions} has not been set.
Property ${api.versions} has not been set.
Property ${api.versions} has not been set.
Property ${namespace} => ${lib.package}
Property ${lib.package} has not been set.
Property ${lib.package} has not been set.
Property ${lib.package} has not been set.
Property ${lib.package} has not been set.
Property ${version.dir} => /Users/stephen/Downloads/googleads-php-lib/src/Google/Api/Ads/${lib.product}/${api.versions}
Property ${lib.product} has not been set.
Property ${api.versions} has not been set.
Property ${lib.product} has not been set.
Property ${api.versions} has not been set.
Property ${lib.product} has not been set.
Property ${api.versions} has not been set.
Property ${lib.product} has not been set.
Property ${api.versions} has not been set.
Property ${wsdl2php.classmap} has not been set.
Property ${wsdl2php.classmap} has not been set.
Property ${wsdl2php.classmap} has not been set.
Property ${wsdl2php.classmap} has not been set.
Property ${wsdl2php.classmap} has not been set.
[PHP Error] Unable to parse classmap as JSON. [line 167 of /Users/stephen/Downloads/googleads-php-lib/build_lib/Wsdl2PhpTask.php]

Better support for Shopping API

I know you've got examples for creating Product Partition Trees (AddProductPartitionTree.php) but not seeing functionality in the class to change bids at the Partition/Product Grouping level.

Hoping you'll be able to expand upon more of the new Shopping API features in the next release.

Alert Service not returning any alert for non MCC account clientCustomerId

Which version of the library are you using?
V201309

Which version of PHP are you using?
PHP Version 5.3.10-1ubuntu3.8

What steps will reproduce the problem?
By running a example for GetAccountAlerts.php under AccountManagement.

What is the expected output? What do you see instead?
Alert for budget and all other types

Please provide any additional information below.
Giving error "An error has occurred: [AlertError.INVALID_CLIENT_ID_SELECTED @ selector.query.clientExternalCustomerIds[0]]"
For single customerId,
See this thread :
https://groups.google.com/forum/#!topic/adwords-api/DRjtU7XSRMU

File inclusion

Hi guys,
Won't it be better to have file inclusion with DIR constant instead of 'Google/Api/Ads/AdWords/...' path ?
For example inclusion in AdsUser.php goes from:

require_once 'Google/Api/Ads/AdWords/Common/Util/Logger.php';
require_once 'Google/Api/Ads/AdWords/Common/Util/SimpleOAuth2Handler.php';
require_once 'Google/Api/Ads/AdWords/Common/Lib/SoapClientFactory.php';
require_once 'Google/Api/Ads/AdWords/Common/Lib/ValidationException.php';

to

require_once __DIR__ . '/../Util/Logger.php';
require_once __DIR__ . '/../Util/SimpleOAuth2Handler.php';
require_once __DIR__ . '/SoapClientFactory.php';
require_once __DIR__ . '/ValidationException.php';

which it's better IMHO.

Regards

Adding XSI type to SOAP request needs to support parsing PHP version labels for PHP installations bundled with Ubuntu.

Copied from:
https://groups.google.com/forum/?fromgroups#!topic/google-doubleclick-for-publishers-api/u1PFQiLCjas

I got a problem by post a soap request to dfp (with the standard php library): I just got the error message "Unmarshalling error: null". Not very concrete... on a dev-server this behaviour does not occur, so I compared both SOAP-Requests and found out, that the only difference was in
"<ns1:authentication xsi:type="ns1:OAuth">*****/ns1:authentication"
The XSI Type (xsi:type="ns1:OAuth") was not send on the other server. I searched in the source code and found the following (dfp_api_2.1.17 is used) in the file "AdsSoapClient.php" line 416:

if (version_compare(PHP_VERSION, '5.2.6', '<') ||
    (PHP_OS == 'Darwin' && version_compare(PHP_VERSION, '5.3.0', '<'))) {
  $addXsiTypes = TRUE;
}

Here is determined, in which PHP Versions the xsi types are added. However, my Version is "5.2.6-1+lenny16" and it seems like it also need these xsi type. So I add the following:

if (version_compare(PHP_VERSION, '5.2.6', '<') ||
    PHP_VERSION === "5.2.6-1+lenny16" ||
    (PHP_OS == 'Darwin' && version_compare(PHP_VERSION, '5.3.0', '<'))) {
  $addXsiTypes = TRUE;
}

I have no idea, whether all of the PHP 5.2.6 versions are affected, so I extend the if-condition only for this special case. My request is to implement this in the next release of dfp php library (so it's not necessary to edit the file for every update). However, if the problem can be generalized, be aware that the command
version_compare(PHP_VERSION, '5.2.6', '=')
return false with the PHP Version '5.2.6-1+lenny16'.

OfflineConversionError.INVALID_CONVERSION_TYPE

Hi,

I want to import via API my offline conversions, but the API returns this error:

Fatal error: Uncaught SoapFault exception: [soap:Server] [OfflineConversionError.INVALID_CONVERSION_TYPE @ operations[0].operand]

For what we read here (https://developers.google.com/adwords/api/docs/reference/v201402/OfflineConversionFeedService.OfflineConversionError.Reason) the error is due to we use as conversionName a name that does not exist. In my case I use 'Solicitudes' as conversionName.

If we obtain via API the conversionNames that we have in our account we found that the one that we are using exist and it's active:

$selector = new Selector();
        $selector->fields = array('Id',
              'Name',
              'Status',
              'Category',
              'NumConversionEvents',
              'NumConvertedClicks',
              'MostRecentConversionDate',
              'CountingType');

var_dump($conversionTrackerService->get($selector)->entries);

returns:

class UploadConversion#98 (14) {
      public $id =>
      string(8) "17555255"
      public $name =>
      string(11) "Solicitudes"
      public $status =>
      string(7) "ENABLED"
      public $category =>
      string(4) "LEAD"
      public $stats =>
      class ConversionTrackerStats#99 (4) {
        ...
      }
      public $viewthroughLookbackWindow =>
      int(30)
      public $isProductAdsChargeable =>
      bool(false)
      public $productAdsChargeableConversionWindow =>
      int(30)
      public $ctcLookbackWindow =>
      int(90)
      public $countingType =>
      string(14) "MANY_PER_CLICK"
      public $defaultRevenueValue =>
      double(1)
      public $alwaysUseDefaultRevenueValue =>
      bool(false)
      public $ConversionTrackerType =>
      string(16) "UploadConversion"
      private $_parameterMap =>
      array(1) {
        ...
      }
    }

Could you explain me why the API returns the OfflineConversionError.INVALID_CONVERSION_TYPE Error?
Am I doing something wrong?

Thanks in advance

We are using this code to uplaod the offline conversions:

const ADWORDS_VERSION = 'v201402';

const USER_AGENT      = 'xxxxxxx';
const DEVELOPER_TOKEN = 'xxxxxxx';
const CLIENT_ID       = 'xxxxxxx';
const CLIENT_SECRET   = 'xxxxxxx';
const REFRESH_TOKEN   = 'xxxxxxx';

$user =  new AdWordsUser(null, null, null, DEVELOPER_TOKEN, null, USER_AGENT);
$oAuth2Info = array(
    'client_id'     => CLIENT_ID,
    'client_secret' => CLIENT_SECRET,
    'refresh_token' => REFRESH_TOKEN);
$user->SetOAuth2Info($oAuth2Info);

$conversionName     = 'Solicitudes';
$conversionTime     = '20140521 182700 Europe/Madrid';
$conversionValue    = 0;
$gClId              = 'CLmLjZWsvb4CFfShtAodnm4APg';

$offlineConversionService = $user->GetService('OfflineConversionFeedService', ADWORDS_VERSION);

// Associate offline conversions with the upload conversion we created.
$feed = new OfflineConversionFeed();
$feed->conversionName = $conversionName;
$feed->conversionTime = $conversionTime;
$feed->conversionValue = $conversionValue;
$feed->googleClickId = $gClId;

$offlineConversionOperation = new OfflineConversionFeedOperation();
$offlineConversionOperation->operator = 'ADD';
$offlineConversionOperation->operand = $feed;

$offlineConversionOperations = array($offlineConversionOperation);
$result = $offlineConversionService->mutate($offlineConversionOperations);

$feed = $result->value[0];

printf('Uploaded offline conversion value of %d for Google Click ID = ' . "'%s' to '%s'.",
    $feed->conversionValue, $feed->googleClickId, $feed->conversionName);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.