Skip to content

Commit aee308d

Browse files
committed
Release 25.4.0.
1 parent 2a10692 commit aee308d

File tree

32 files changed

+2424
-39
lines changed

32 files changed

+2424
-39
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
### 25.4.0
2+
3+
##### DFP
4+
5+
* Added `perform action` examples for core services.
6+
* Added `CreateNativeCreatives` example.
7+
* Fixed the `CreateProposals` example.
8+
* Added some `update` examples for reconciliation services.
9+
110
### 25.3.0
211

312
##### AdWords

examples/AdWords/v201609/AdvancedOperations/AddUniversalAppCampaign.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public static function runExample(AdWordsServices $adWordsServices,
110110
// Optional: You can set up to 10 image assets for your campaign.
111111
// See UploadImage.php for an example on how to upload images.
112112
//
113-
// $universalAppSetting->imageMediaIds = array(INSERT_IMAGE_MEDIA_ID_HERE);
113+
// $universalAppSetting->imageMediaIds = [INSERT_IMAGE_MEDIA_ID_HERE];
114114

115115
// Optimize this campaign for getting new users for your app.
116116
$universalAppSetting->setUniversalAppBiddingStrategyGoalType(
@@ -123,10 +123,10 @@ public static function runExample(AdWordsServices $adWordsServices,
123123
// Conversion type IDs can be retrieved using ConversionTrackerService.get.
124124
//
125125
// $campaign->selectiveOptimization = new SelectiveOptimization();
126-
// $campaign->selectiveOptimization->conversionTypeIds = array(
126+
// $campaign->selectiveOptimization->conversionTypeIds = [
127127
// INSERT_CONVERSION_TYPE_ID_1_HERE,
128128
// INSERT_CONVERSION_TYPE_ID_2_HERE
129-
// );
129+
// ];
130130

131131
// Optional: Set the campaign settings for Advanced location options.
132132
$geoTargetTypeSetting = new GeoTargetTypeSetting();

examples/AdWords/v201702/AdvancedOperations/AddUniversalAppCampaign.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public static function runExample(AdWordsServices $adWordsServices,
110110
// Optional: You can set up to 10 image assets for your campaign.
111111
// See UploadImage.php for an example on how to upload images.
112112
//
113-
// $universalAppSetting->imageMediaIds = array(INSERT_IMAGE_MEDIA_ID_HERE);
113+
// $universalAppSetting->imageMediaIds = [INSERT_IMAGE_MEDIA_ID_HERE];
114114

115115
// Optimize this campaign for getting new users for your app.
116116
$universalAppSetting->setUniversalAppBiddingStrategyGoalType(
@@ -123,10 +123,10 @@ public static function runExample(AdWordsServices $adWordsServices,
123123
// Conversion type IDs can be retrieved using ConversionTrackerService.get.
124124
//
125125
// $campaign->selectiveOptimization = new SelectiveOptimization();
126-
// $campaign->selectiveOptimization->conversionTypeIds = array(
126+
// $campaign->selectiveOptimization->conversionTypeIds = [
127127
// INSERT_CONVERSION_TYPE_ID_1_HERE,
128128
// INSERT_CONVERSION_TYPE_ID_2_HERE
129-
// );
129+
// ];
130130

131131
// Optional: Set the campaign settings for Advanced location options.
132132
$geoTargetTypeSetting = new GeoTargetTypeSetting();

examples/Dfp/v201702/CreativeService/CreateCreatives.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
use Google\AdsApi\Dfp\DfpServices;
2323
use Google\AdsApi\Dfp\DfpSession;
2424
use Google\AdsApi\Dfp\DfpSessionBuilder;
25-
use Google\AdsApi\Dfp\v201702\Size;
2625
use Google\AdsApi\Dfp\v201702\CreativeAsset;
27-
use Google\AdsApi\Dfp\v201702\ImageCreative;
2826
use Google\AdsApi\Dfp\v201702\CreativeService;
27+
use Google\AdsApi\Dfp\v201702\ImageCreative;
28+
use Google\AdsApi\Dfp\v201702\Size;
2929

3030
/**
3131
* Creates image creatives.
@@ -40,8 +40,7 @@ class CreateCreatives {
4040

4141
public static function runExample(DfpServices $dfpServices,
4242
DfpSession $session, $advertiserId) {
43-
$creativeService =
44-
$dfpServices->get($session, CreativeService::class);
43+
$creativeService = $dfpServices->get($session, CreativeService::class);
4544

4645
$imageCreative = new ImageCreative();
4746
$imageCreative->setName('Image creative #'. uniqid());
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
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\Dfp\v201702\CreativeService;
18+
19+
require '../../../../vendor/autoload.php';
20+
21+
use Google\AdsApi\Common\OAuth2TokenBuilder;
22+
use Google\AdsApi\Dfp\DfpServices;
23+
use Google\AdsApi\Dfp\DfpSession;
24+
use Google\AdsApi\Dfp\DfpSessionBuilder;
25+
use Google\AdsApi\Dfp\v201702\AssetCreativeTemplateVariableValue;
26+
use Google\AdsApi\Dfp\v201702\CreativeAsset;
27+
use Google\AdsApi\Dfp\v201702\CreativeService;
28+
use Google\AdsApi\Dfp\v201702\Size;
29+
use Google\AdsApi\Dfp\v201702\StringCreativeTemplateVariableValue;
30+
use Google\AdsApi\Dfp\v201702\TemplateCreative;
31+
use Google\AdsApi\Dfp\v201702\UrlCreativeTemplateVariableValue;
32+
33+
/**
34+
* Creates native creatives.
35+
*
36+
* This example is meant to be run from a command line (not as a webpage) and
37+
* requires that you've setup an `adsapi_php.ini` file in your home directory
38+
* with your API credentials and settings. See `README.md` for more info.
39+
*/
40+
class CreateNativeCreatives {
41+
42+
const ADVERTISER_ID = 'INSERT_ADVERTISER_ID_HERE';
43+
44+
public static function runExample(DfpServices $dfpServices,
45+
DfpSession $session, $advertiserId) {
46+
$creativeService = $dfpServices->get($session, CreativeService::class);
47+
48+
// Use the system defined native app install creative template.
49+
$nativeAppInstallTemplateId = 10004400;
50+
51+
// Use 1x1 as the size for native creatives.
52+
$size = new Size();
53+
$size->setWidth(1);
54+
$size->setHeight(1);
55+
$size->setIsAspectRatio(false);
56+
57+
// Create a native app install creative for the Pie Noon app.
58+
$nativeAppInstallCreative = new TemplateCreative();
59+
$nativeAppInstallCreative->setName('Native creative #' . uniqid());
60+
$nativeAppInstallCreative->setAdvertiserId($advertiserId);
61+
$nativeAppInstallCreative->setDestinationUrl(
62+
'https://play.google.com/store/apps/details?id=com.google.fpl.pie_noon'
63+
);
64+
$nativeAppInstallCreative
65+
->setCreativeTemplateId($nativeAppInstallTemplateId);
66+
$nativeAppInstallCreative->setSize($size);
67+
68+
// Set the headline.
69+
$headlineVariableValue = new StringCreativeTemplateVariableValue();
70+
$headlineVariableValue->setUniqueName('Headline');
71+
$headlineVariableValue->setValue('Pie Noon');
72+
$variableValues = [$headlineVariableValue];
73+
74+
// Set the body text.
75+
$bodyVariableValue = new StringCreativeTemplateVariableValue();
76+
$bodyVariableValue->setUniqueName('Body');
77+
$bodyVariableValue->setValue('Try multi-screen mode!');
78+
$variableValues[] = $bodyVariableValue;
79+
80+
// Set the image asset.
81+
$imageVariableValue = new AssetCreativeTemplateVariableValue();
82+
$imageVariableValue->setUniqueName('Image');
83+
$imageAsset = new CreativeAsset();
84+
$imageAsset->setFileName('image' . uniqid() . '.png');
85+
$imageAsset->setAssetByteArray(file_get_contents(
86+
'https://lh4.ggpht.com/GIGNKdGHMEHFDw6TM2bgAUDKPQQRIReKZPqEpMeEhZOPYnTd'
87+
. 'OQGaSpGSEZflIFs0iw=h300'
88+
));
89+
$imageVariableValue->setAsset($imageAsset);
90+
$variableValues[] = $imageVariableValue;
91+
92+
// Set the price.
93+
$priceVariableValue = new StringCreativeTemplateVariableValue();
94+
$priceVariableValue->setUniqueName('Price');
95+
$priceVariableValue->setValue('Free');
96+
$variableValues[] = $priceVariableValue;
97+
98+
// Set app icon image asset.
99+
$appIconVariableValue = new AssetCreativeTemplateVariableValue();
100+
$appIconVariableValue->setUniqueName('Appicon');
101+
$appIconAsset = new CreativeAsset();
102+
$appIconAsset->setFileName('icon' . uniqid() . '.png');
103+
$appIconAsset->setAssetByteArray(file_get_contents(
104+
'https://lh6.ggpht.com/Jzvjne5CLs6fJ1MHF-XeuUfpABzl0YNMlp4RpHnvPRCIj4--'
105+
. 'eTDwtyouwUDzVVekXw=w300'
106+
));
107+
$appIconVariableValue->setAsset($appIconAsset);
108+
$variableValues[] = $appIconVariableValue;
109+
110+
// Set the call to action text.
111+
$callToActionVariableValue = new StringCreativeTemplateVariableValue();
112+
$callToActionVariableValue->setUniqueName('Calltoaction');
113+
$callToActionVariableValue->setValue('Install');
114+
$variableValues[] = $callToActionVariableValue;
115+
116+
// Set the star rating.
117+
$starRatingVariableValue = new StringCreativeTemplateVariableValue();
118+
$starRatingVariableValue->setUniqueName('Starrating');
119+
$starRatingVariableValue->setValue('4');
120+
$variableValues[] = $starRatingVariableValue;
121+
122+
// Set the store type.
123+
$storeVariableValue = new StringCreativeTemplateVariableValue();
124+
$storeVariableValue->setUniqueName('Store');
125+
$storeVariableValue->setValue('Google Play');
126+
$variableValues[] = $storeVariableValue;
127+
128+
// Set the deep link URL.
129+
$deepLinkVariableValue = new UrlCreativeTemplateVariableValue();
130+
$deepLinkVariableValue->setUniqueName('DeeplinkclickactionURL');
131+
$deepLinkVariableValue
132+
->setValue('market://details?id=com.google.fpl.pie_noon');
133+
$variableValues[] = $deepLinkVariableValue;
134+
135+
$nativeAppInstallCreative
136+
->setCreativeTemplateVariableValues($variableValues);
137+
138+
// Create the native creatives on the server.
139+
$results = $creativeService->createCreatives([$nativeAppInstallCreative]);
140+
141+
// Print out some information for each created native creative.
142+
foreach ($results as $i => $nativeAppInstallCreative) {
143+
printf(
144+
"%d) Native creative with ID %d and name '%s' was created and can be "
145+
. "previewed at: '%s'.\n",
146+
$i,
147+
$nativeAppInstallCreative->getId(),
148+
$nativeAppInstallCreative->getName(),
149+
$nativeAppInstallCreative->getPreviewUrl()
150+
);
151+
}
152+
}
153+
154+
public static function main() {
155+
// Generate a refreshable OAuth2 credential for authentication.
156+
$oAuth2Credential = (new OAuth2TokenBuilder())
157+
->fromFile()
158+
->build();
159+
160+
// Construct an API session configured from a properties file and the OAuth2
161+
// credentials above.
162+
$session = (new DfpSessionBuilder())
163+
->fromFile()
164+
->withOAuth2Credential($oAuth2Credential)
165+
->build();
166+
167+
self::runExample(new DfpServices(), $session, intval(self::ADVERTISER_ID));
168+
}
169+
}
170+
171+
CreateNativeCreatives::main();

examples/Dfp/v201702/CreativeService/GetAllCreatives.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ class GetAllCreatives {
3636

3737
public static function runExample(DfpServices $dfpServices,
3838
DfpSession $session) {
39-
$creativeService =
40-
$dfpServices->get($session, CreativeService::class);
39+
$creativeService = $dfpServices->get($session, CreativeService::class);
4140

4241
// Create a statement to select creatives.
4342
$pageSize = StatementBuilder::SUGGESTED_PAGE_LIMIT;

examples/Dfp/v201702/CreativeService/GetImageCreatives.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ class GetImageCreatives {
3636

3737
public static function runExample(DfpServices $dfpServices,
3838
DfpSession $session) {
39-
$creativeService =
40-
$dfpServices->get($session, CreativeService::class);
39+
$creativeService = $dfpServices->get($session, CreativeService::class);
4140

4241
// Create a statement to select creatives.
4342
$pageSize = StatementBuilder::SUGGESTED_PAGE_LIMIT;
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
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\Dfp\v201702\CustomTargetingService;
18+
19+
require '../../../../vendor/autoload.php';
20+
21+
use Google\AdsApi\Common\OAuth2TokenBuilder;
22+
use Google\AdsApi\Dfp\DfpServices;
23+
use Google\AdsApi\Dfp\DfpSession;
24+
use Google\AdsApi\Dfp\DfpSessionBuilder;
25+
use Google\AdsApi\Dfp\Util\v201702\StatementBuilder;
26+
use Google\AdsApi\Dfp\v201702\CustomTargetingService;
27+
use Google\AdsApi\Dfp\v201702\DeleteCustomTargetingKeys as DeleteCustomTargetingKeysAction;
28+
29+
/**
30+
* Deletes custom targeting keys.
31+
*
32+
* This example is meant to be run from a command line (not as a webpage) and
33+
* requires that you've setup an `adsapi_php.ini` file in your home directory
34+
* with your API credentials and settings. See `README.md` for more info.
35+
*/
36+
class DeleteCustomTargetingKeys {
37+
38+
const CUSTOM_TARGETING_KEY_ID = 'INSERT_CUSTOM_TARGETING_KEY_ID_HERE';
39+
40+
public static function runExample(DfpServices $dfpServices,
41+
DfpSession $session, $customTargetingKeyId) {
42+
$customTargetingService =
43+
$dfpServices->get($session, CustomTargetingService::class);
44+
45+
// Create a statement to select the custom targeting keys to delete.
46+
$pageSize = StatementBuilder::SUGGESTED_PAGE_LIMIT;
47+
$statementBuilder = (new StatementBuilder())
48+
->where('id = :id')
49+
->orderBy('id ASC')
50+
->limit($pageSize)
51+
->withBindVariableValue('id', $customTargetingKeyId);
52+
53+
// Retrieve a small amount of custom targeting keys at a time, paging
54+
// through until all custom targeting keys have been retrieved.
55+
$totalResultSetSize = 0;
56+
do {
57+
$page = $customTargetingService->getCustomTargetingKeysByStatement(
58+
$statementBuilder->toStatement());
59+
60+
// Print out some information for the custom targeting keys to be deleted.
61+
if ($page->getResults() !== null) {
62+
$totalResultSetSize = $page->getTotalResultSetSize();
63+
$i = $page->getStartIndex();
64+
foreach ($page->getResults() as $customTargetingKey) {
65+
printf(
66+
"%d) Custom targeting key with ID %d, " .
67+
"name '%s', " .
68+
"and display name '%s' will be deleted.\n",
69+
$i++,
70+
$customTargetingKey->getId(),
71+
$customTargetingKey->getName(),
72+
$customTargetingKey->getDisplayName()
73+
);
74+
}
75+
}
76+
77+
$statementBuilder->increaseOffsetBy($pageSize);
78+
} while ($statementBuilder->getOffset() < $totalResultSetSize);
79+
80+
printf("Total number of custom targeting keys to be deleted: %d\n",
81+
$totalResultSetSize);
82+
83+
if ($totalResultSetSize > 0) {
84+
// Remove limit and offset from statement so we can reuse the statement.
85+
$statementBuilder->removeLimitAndOffset();
86+
87+
// Create and perform action.
88+
$action = new DeleteCustomTargetingKeysAction();
89+
$result = $customTargetingService->performCustomTargetingKeyAction(
90+
$action, $statementBuilder->toStatement());
91+
92+
if ($result !== null && $result->getNumChanges() > 0) {
93+
printf("Number of custom targeting keys deleted: %d\n",
94+
$result->getNumChanges());
95+
} else {
96+
printf("No custom targeting keys were deleted.\n");
97+
}
98+
}
99+
}
100+
101+
public static function main() {
102+
// Generate a refreshable OAuth2 credential for authentication.
103+
$oAuth2Credential = (new OAuth2TokenBuilder())
104+
->fromFile()
105+
->build();
106+
107+
// Construct an API session configured from a properties file and the OAuth2
108+
// credentials above.
109+
$session = (new DfpSessionBuilder())
110+
->fromFile()
111+
->withOAuth2Credential($oAuth2Credential)
112+
->build();
113+
114+
self::runExample(
115+
new DfpServices(), $session, intval(self::CUSTOM_TARGETING_KEY_ID));
116+
}
117+
}
118+
119+
DeleteCustomTargetingKeys::main();

0 commit comments

Comments
 (0)