Skip to content

Commit 86d8883

Browse files
author
Thang Duong
committed
Release 32.0.0.
1 parent ff3232c commit 86d8883

File tree

2,481 files changed

+1617584
-41093
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,481 files changed

+1617584
-41093
lines changed

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
### 32.0.0
2+
3+
##### AdWords
4+
5+
* Fixed
6+
[issue #378](https://github.com/googleads/googleads-php-lib/issues/378).
7+
8+
##### DFP
9+
10+
* Added support and examples for v201711.
11+
* Added CdnConfigurationService and examples.
12+
* Removed support for v201611.
13+
* Removed examples for v201702.
14+
15+
##### Common
16+
17+
* Included WSDL files for all SOAP services and they're now used for making
18+
SOAP calls instead of live WSDLs. Therefore, the WSDL caching feature is
19+
deprecated (`wsdlCache` in `adsapi_php.ini` is now ignored). The feature
20+
will be removed completely in the next major release.
21+
122
### 31.0.0
223

324
##### AdWords

UPGRADING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ DFP utilities have minor changes, most remain the same.
180180

181181
| | Old library | New library
182182
------------------ | --------------------------------------------------------------------------------------------------------------------------------------------- | -----------
183-
Date times utility | Called [DateTimeUtils](https://github.com/googleads/googleads-php-lib/blob/deprecated/src/Google/Api/Ads/Dfp/Util/v201611/DateTimeUtils.php). | Split and renamed to [DfpDateTimes](https://github.com/googleads/googleads-php-lib/blob/master/src/Google/AdsApi/Dfp/Util/v201611/DfpDateTimes.php) and [DfpDates](https://github.com/googleads/googleads-php-lib/blob/master/src/Google/AdsApi/Dfp/Util/v201611/DfpDates.php), some obsolete methods removed.
183+
Date times utility | Called [DateTimeUtils](https://github.com/googleads/googleads-php-lib/blob/deprecated/src/Google/Api/Ads/Dfp/Util/v201711/DateTimeUtils.php). | Split and renamed to [DfpDateTimes](https://github.com/googleads/googleads-php-lib/blob/master/src/Google/AdsApi/Dfp/Util/v201711/DfpDateTimes.php) and [DfpDates](https://github.com/googleads/googleads-php-lib/blob/master/src/Google/AdsApi/Dfp/Util/v201711/DfpDates.php), some obsolete methods removed.
184184
Report downloader | Uses Curl ext. | Uses Guzzle.
185185

186186
## Examples

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"guzzlehttp/guzzle": "^6.0",
1010
"guzzlehttp/psr7": "^1.2",
1111
"monolog/monolog": "^1.17.1",
12-
"phpdocumentor/reflection-docblock": "^4.0.0 || ^3.0.3",
12+
"phpdocumentor/reflection-docblock": "^3.0.3",
1313
"symfony/serializer": "^2.8.0 || ^3.0.3"
1414
},
1515
"require-dev": {

examples/AdWords/adsapi_php.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ clientCustomerId = "INSERT_CLIENT_CUSTOMER_ID_HERE"
4040
[SOAP]
4141
; Optional SOAP settings. See SoapSettingsBuilder.php for more information.
4242
; compressionLevel = <COMPRESSION_LEVEL>
43-
; wsdlCache = <WSDL_CACHE>
4443

4544
[CONNECTION]
4645
; Optional proxy settings to be used by requests.

examples/AdWords/v201702/Reporting/DownloadCriteriaReportWithAwql.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,14 @@ public static function runExample(AdWordsSession $session, $reportFormat) {
3838

3939
// Download report as a string.
4040
$reportDownloader = new ReportDownloader($session);
41+
// Optional: If you need to adjust report settings just for this one
42+
// request, you can create and supply the settings override here. Otherwise,
43+
// default values from the configuration file (adsapi_php.ini) are used.
44+
$reportSettingsOverride = (new ReportSettingsBuilder())
45+
->includeZeroImpressions(false)
46+
->build();
4147
$reportDownloadResult = $reportDownloader->downloadReportWithAwql(
42-
$reportQuery, $reportFormat);
48+
$reportQuery, $reportFormat, $reportSettingsOverride);
4349
print "Report was downloaded and printed below:\n";
4450
print $reportDownloadResult->getAsString();
4551
}
@@ -50,21 +56,13 @@ public static function main() {
5056
->fromFile()
5157
->build();
5258

53-
// See: ReportSettingsBuilder for more options (e.g., suppress headers)
54-
// or set them in your adsapi_php.ini file.
55-
$reportSettings = (new ReportSettingsBuilder())
56-
->fromFile()
57-
->includeZeroImpressions(false)
58-
->build();
59-
6059
// See: AdWordsSessionBuilder for setting a client customer ID that is
6160
// different from that specified in your adsapi_php.ini file.
6261
// Construct an API session configured from a properties file and the OAuth2
6362
// credentials above.
6463
$session = (new AdWordsSessionBuilder())
6564
->fromFile()
6665
->withOAuth2Credential($oAuth2Credential)
67-
->withReportSettings($reportSettings)
6866
->build();
6967

7068
self::runExample($session, DownloadFormat::CSV);

examples/AdWords/v201702/Reporting/DownloadCriteriaReportWithSelector.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,14 @@ public static function runExample(AdWordsSession $session, $filePath) {
5959

6060
// Download report.
6161
$reportDownloader = new ReportDownloader($session);
62-
$reportDownloadResult =
63-
$reportDownloader->downloadReport($reportDefinition);
62+
// Optional: If you need to adjust report settings just for this one
63+
// request, you can create and supply the settings override here. Otherwise,
64+
// default values from the configuration file (adsapi_php.ini) are used.
65+
$reportSettingsOverride = (new ReportSettingsBuilder())
66+
->includeZeroImpressions(false)
67+
->build();
68+
$reportDownloadResult = $reportDownloader->downloadReport(
69+
$reportDefinition, $reportSettingsOverride);
6470
$reportDownloadResult->saveToFile($filePath);
6571
printf("Report with name '%s' was downloaded to '%s'.\n",
6672
$reportDefinition->getReportName(), $filePath);
@@ -72,21 +78,13 @@ public static function main() {
7278
->fromFile()
7379
->build();
7480

75-
// See: ReportSettingsBuilder for more options (e.g., suppress headers)
76-
// or set them in your adsapi_php.ini file.
77-
$reportSettings = (new ReportSettingsBuilder())
78-
->fromFile()
79-
->includeZeroImpressions(false)
80-
->build();
81-
8281
// See: AdWordsSessionBuilder for setting a client customer ID that is
8382
// different from that specified in your adsapi_php.ini file.
8483
// Construct an API session configured from a properties file and the OAuth2
8584
// credentials above.
8685
$session = (new AdWordsSessionBuilder())
8786
->fromFile()
8887
->withOAuth2Credential($oAuth2Credential)
89-
->withReportSettings($reportSettings)
9088
->build();
9189

9290
$filePath = sprintf(
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
<?php
2+
/**
3+
* Copyright 2017 Google Inc. All Rights Reserved.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
namespace Google\AdsApi\Examples\AdWords\v201710\AdvancedOperations;
18+
19+
require __DIR__ . '/../../../../vendor/autoload.php';
20+
21+
use Google\AdsApi\AdWords\AdWordsServices;
22+
use Google\AdsApi\AdWords\AdWordsSession;
23+
use Google\AdsApi\AdWords\AdWordsSessionBuilder;
24+
use Google\AdsApi\AdWords\v201710\cm\CampaignSharedSetService;
25+
use Google\AdsApi\AdWords\v201710\cm\Criterion;
26+
use Google\AdsApi\AdWords\v201710\cm\CriterionType;
27+
use Google\AdsApi\AdWords\v201710\cm\Operator;
28+
use Google\AdsApi\AdWords\v201710\cm\Predicate;
29+
use Google\AdsApi\AdWords\v201710\cm\PredicateOperator;
30+
use Google\AdsApi\AdWords\v201710\cm\Paging;
31+
use Google\AdsApi\AdWords\v201710\cm\Selector;
32+
use Google\AdsApi\AdWords\v201710\cm\SharedCriterion;
33+
use Google\AdsApi\AdWords\v201710\cm\SharedCriterionOperation;
34+
use Google\AdsApi\AdWords\v201710\cm\SharedCriterionService;
35+
use Google\AdsApi\AdWords\v201710\cm\SharedSetType;
36+
use Google\AdsApi\Common\OAuth2TokenBuilder;
37+
38+
/**
39+
* This example demonstrates how to find and remove shared sets and shared set
40+
* criteria.
41+
*/
42+
class FindAndRemoveCriteriaFromSharedSet {
43+
44+
const CAMPAIGN_ID = 'INSERT_CAMPAIGN_ID_HERE';
45+
const PAGE_LIMIT = 100;
46+
47+
public static function runExample(AdWordsServices $adWordsServices,
48+
AdWordsSession $session, $campaignId) {
49+
$campaignSharedSetService =
50+
$adWordsServices->get($session, CampaignSharedSetService::class);
51+
52+
// Create selector.
53+
$selector = new Selector();
54+
$selector->setFields([
55+
'SharedSetId', 'CampaignId', 'SharedSetName', 'SharedSetType']);
56+
$selector->setPredicates([
57+
new Predicate('CampaignId', PredicateOperator::EQUALS, [$campaignId]),
58+
new Predicate('SharedSetType', PredicateOperator::IN, [
59+
SharedSetType::NEGATIVE_KEYWORDS, SharedSetType::NEGATIVE_PLACEMENTS
60+
])
61+
]);
62+
$selector->setPaging(new Paging(0, self::PAGE_LIMIT));
63+
64+
$sharedSetIds = [];
65+
$totalNumEntries = 0;
66+
do {
67+
// Make the get request.
68+
$page = $campaignSharedSetService->get($selector);
69+
70+
// Display results.
71+
if ($page->getEntries() !== null) {
72+
$totalNumEntries = $page->getTotalNumEntries();
73+
foreach ($page->getEntries() as $campaignSharedSet) {
74+
$sharedSetIds[] = strval($campaignSharedSet->getSharedSetId());
75+
printf(
76+
"Campaign shared set ID %d and name '%s' found for"
77+
. " campaign ID %d.\n",
78+
$campaignSharedSet->getSharedSetId(),
79+
$campaignSharedSet->getSharedSetName(),
80+
$campaignSharedSet->getCampaignId()
81+
);
82+
}
83+
}
84+
85+
// Advance the paging index.
86+
$selector->getPaging()->setStartIndex(
87+
$selector->getPaging()->getStartIndex() + self::PAGE_LIMIT);
88+
} while ($selector->getPaging()->getStartIndex() < $totalNumEntries);
89+
90+
if (empty($sharedSetIds)) {
91+
printf("No shared sets found for campaign ID %d.\n", $campaignId);
92+
return;
93+
}
94+
95+
// Next, retrieve criterion IDs for all found shared sets.
96+
$sharedCriterionService = $adWordsServices->get($session,
97+
SharedCriterionService::class);
98+
99+
// Create selector.
100+
$selector = new Selector();
101+
$selector->setFields([
102+
'SharedSetId', 'Id', 'KeywordText', 'KeywordMatchType', 'PlacementUrl'
103+
]);
104+
$selector->setPredicates([
105+
new Predicate('SharedSetId', PredicateOperator::IN, $sharedSetIds)]);
106+
$selector->setPaging(new Paging(0, self::PAGE_LIMIT));
107+
108+
$removeCriterionOperations = [];
109+
$totalNumEntries = 0;
110+
do {
111+
// Make the get request.
112+
$page = $sharedCriterionService->get($selector);
113+
114+
// Display results.
115+
if ($page->getEntries() !== null) {
116+
$totalNumEntries = $page->getTotalNumEntries();
117+
foreach ($page->getEntries() as $sharedCriterion) {
118+
if (CriterionType::KEYWORD
119+
=== $sharedCriterion->getCriterion()->getType()) {
120+
$keyword = $sharedCriterion->getCriterion();
121+
printf(
122+
"Shared negative keyword with ID %d and text '%s' was found.\n",
123+
$keyword->getId(),
124+
$keyword->getText()
125+
);
126+
} else if (CriterionType::PLACEMENT
127+
=== $sharedCriterion->getCriterion()->getType()) {
128+
$placement = $sharedCriterion->getCriterion();
129+
printf(
130+
"Shared negative placement with ID %d and URL '%s' was"
131+
. " found.\n",
132+
$placement->getId(),
133+
$placement->getUrl()
134+
);
135+
} else {
136+
printf("Shared criterion with ID %d was found.\n",
137+
$sharedCriterion->getCriterion()->getId());
138+
}
139+
140+
$criterionToRemove = new Criterion();
141+
$criterionToRemove->setId(
142+
$sharedCriterion->getCriterion()->getId());
143+
144+
$sharedCriterionToRemove = new SharedCriterion();
145+
$sharedCriterionToRemove->setCriterion($criterionToRemove);
146+
$sharedCriterionToRemove->setSharedSetId(
147+
$sharedCriterion->getSharedSetId());
148+
149+
// Create an operation to remove this criterion.
150+
$removeCriterionOperation = new SharedCriterionOperation();
151+
$removeCriterionOperation->setOperator(Operator::REMOVE);
152+
$removeCriterionOperation->setOperand($sharedCriterionToRemove);
153+
154+
$removeCriterionOperations[] = $removeCriterionOperation;
155+
}
156+
}
157+
158+
// Advance the paging index.
159+
$selector->getPaging()->setStartIndex(
160+
$selector->getPaging()->getStartIndex() + self::PAGE_LIMIT);
161+
} while ($selector->getPaging()->getStartIndex() < $totalNumEntries);
162+
163+
// Finally, remove the criteria.
164+
if (empty($removeCriterionOperations)) {
165+
printf("No shared criteria to remove.\n");
166+
} else {
167+
$result = $sharedCriterionService->mutate($removeCriterionOperations);
168+
foreach ($result->getValue() as $removedCriterion) {
169+
printf(
170+
"Shared criterion ID %d was successfully removed from shared set"
171+
. " ID %d.\n",
172+
$removedCriterion->getCriterion()->getId(),
173+
$removedCriterion->getSharedSetId()
174+
);
175+
}
176+
}
177+
}
178+
179+
public static function main() {
180+
// Generate a refreshable OAuth2 credential for authentication.
181+
$oAuth2Credential = (new OAuth2TokenBuilder())
182+
->fromFile()
183+
->build();
184+
185+
// Construct an API session configured from a properties file and the OAuth2
186+
// credentials above.
187+
$session = (new AdWordsSessionBuilder())
188+
->fromFile()
189+
->withOAuth2Credential($oAuth2Credential)
190+
->build();
191+
self::runExample(
192+
new AdWordsServices(), $session, intval(self::CAMPAIGN_ID));
193+
}
194+
}
195+
196+
FindAndRemoveCriteriaFromSharedSet::main();

0 commit comments

Comments
 (0)