Skip to content

Commit fd9f179

Browse files
committed
Release 16.1.0.
1 parent afcf92c commit fd9f179

File tree

265 files changed

+251168
-4858
lines changed

Some content is hidden

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

265 files changed

+251168
-4858
lines changed

ChangeLog.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
### 16.1.0
2+
3+
AdWords:
4+
- Added support and examples for v201702.
5+
- Fixed
6+
[issue #191](https://github.com/googleads/googleads-php-lib/issues/191).
7+
8+
DFP:
9+
- Fixed an unmarshalling issue with `ApiError`.
10+
111
### 16.0.0
212

313
AdWords:
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?php
2+
/**
3+
* This example accepts a pending invitation to link your AdWords account to a
4+
* Google Merchant Center account.
5+
*
6+
* Copyright 2017, Google Inc. All Rights Reserved.
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License");
9+
* you may not use this file except in compliance with the License.
10+
* You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*
20+
* @package GoogleApiAdsAdWords
21+
* @subpackage v201702
22+
* @category WebServices
23+
* @copyright 2016, Google Inc. All Rights Reserved.
24+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License,
25+
* Version 2.0
26+
*/
27+
28+
// Include the initialization file
29+
require_once dirname(dirname(__FILE__)) . '/init.php';
30+
31+
// Enter parameters required by the code example.
32+
$serviceLinkId = 'INSERT_SERVICE_LINK_ID_HERE';
33+
34+
/**
35+
* Runs the example.
36+
* @param AdWordsUser $user the user to run the example with
37+
* @param int $serviceLinkId the service link ID to accept
38+
*/
39+
function AcceptServiceLinkExample(AdWordsUser $user, $serviceLinkId) {
40+
// Get the service, which loads the required classes.
41+
$customerService = $user->GetService('CustomerService', ADWORDS_VERSION);
42+
43+
// Create service link and set the status to ACTIVE.
44+
$serviceLink = new ServiceLink();
45+
$serviceLink->serviceLinkId = $serviceLinkId;
46+
$serviceLink->serviceType = 'MERCHANT_CENTER';
47+
$serviceLink->linkStatus = 'ACTIVE';
48+
49+
// Create operation.
50+
$operation = new ServiceLinkOperation();
51+
$operation->operator = 'SET';
52+
$operation->operand = $serviceLink;
53+
54+
$operations = array($operation);
55+
56+
// Make the mutate request.
57+
$serviceLinks = $customerService->mutateServiceLinks($operations);
58+
59+
// Display the results.
60+
foreach ($serviceLinks as $serviceLink) {
61+
printf(
62+
"Service link with service link ID %d, type '%s' updated to status: %s."
63+
. "\n",
64+
$serviceLink->serviceLinkId,
65+
$serviceLink->serviceType,
66+
$serviceLink->linkStatus
67+
);
68+
}
69+
}
70+
71+
// Don't run the example if the file is being included.
72+
if (__FILE__ != realpath($_SERVER['PHP_SELF'])) {
73+
return;
74+
}
75+
76+
try {
77+
// Get AdWordsUser from credentials in "../auth.ini"
78+
// relative to the AdWordsUser.php file's directory.
79+
$user = new AdWordsUser();
80+
81+
// Log every SOAP XML request and response.
82+
$user->LogAll();
83+
84+
// Run the example.
85+
AcceptServiceLinkExample($user, $serviceLinkId);
86+
} catch (Exception $e) {
87+
printf("An error has occurred: %s\n", $e->getMessage());
88+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?php
2+
/**
3+
* This example creates a new account under an AdWords manager account. Note:
4+
* this example must be run using the credentials of an AdWords manager account,
5+
* and by default the new account will only be accessible via the parent AdWords
6+
* manager account.
7+
*
8+
* PHP version 5
9+
*
10+
* Copyright 2017, Google Inc. All Rights Reserved.
11+
*
12+
* Licensed under the Apache License, Version 2.0 (the "License");
13+
* you may not use this file except in compliance with the License.
14+
* You may obtain a copy of the License at
15+
*
16+
* http://www.apache.org/licenses/LICENSE-2.0
17+
*
18+
* Unless required by applicable law or agreed to in writing, software
19+
* distributed under the License is distributed on an "AS IS" BASIS,
20+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21+
* See the License for the specific language governing permissions and
22+
* limitations under the License.
23+
*
24+
* @package GoogleApiAdsAdWords
25+
* @subpackage v201702
26+
* @category WebServices
27+
* @copyright 2016, Google Inc. All Rights Reserved.
28+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License,
29+
* Version 2.0
30+
*/
31+
32+
// Include the initialization file
33+
require_once dirname(dirname(__FILE__)) . '/init.php';
34+
35+
/**
36+
* Runs the example.
37+
* @param AdWordsUser $user the user to run the example with
38+
*/
39+
function CreateAccountExample(AdWordsUser $user) {
40+
// Get the service, which loads the required classes.
41+
$managedCustomerService =
42+
$user->GetService('ManagedCustomerService', ADWORDS_VERSION);
43+
44+
// Create customer.
45+
$customer = new ManagedCustomer();
46+
$customer->name = 'Account #' . uniqid();
47+
$customer->currencyCode = 'EUR';
48+
$customer->dateTimeZone = 'Europe/London';
49+
50+
// Create operation.
51+
$operation = new ManagedCustomerOperation();
52+
$operation->operator = 'ADD';
53+
$operation->operand = $customer;
54+
55+
$operations = array($operation);
56+
57+
// Make the mutate request.
58+
$result = $managedCustomerService->mutate($operations);
59+
60+
// Display result.
61+
$customer = $result->value[0];
62+
printf("Account with customer ID '%s' was created.\n",
63+
$customer->customerId);
64+
}
65+
66+
// Don't run the example if the file is being included.
67+
if (__FILE__ != realpath($_SERVER['PHP_SELF'])) {
68+
return;
69+
}
70+
71+
try {
72+
// Get AdWordsUser from credentials in "../auth.ini"
73+
// relative to the AdWordsUser.php file's directory.
74+
$user = new AdWordsUser();
75+
76+
// Log every SOAP XML request and response.
77+
$user->LogAll();
78+
79+
// Run the example.
80+
CreateAccountExample($user);
81+
} catch (Exception $e) {
82+
printf("An error has occurred: %s\n", $e->getMessage());
83+
}
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
<?php
2+
/**
3+
* This example gets the changes in the account during the last 24 hours.
4+
* Note: this example must be run using the credentials of an ad-serving
5+
* account.
6+
*
7+
* PHP version 5
8+
*
9+
* Copyright 2017, Google Inc. All Rights Reserved.
10+
*
11+
* Licensed under the Apache License, Version 2.0 (the "License");
12+
* you may not use this file except in compliance with the License.
13+
* You may obtain a copy of the License at
14+
*
15+
* http://www.apache.org/licenses/LICENSE-2.0
16+
*
17+
* Unless required by applicable law or agreed to in writing, software
18+
* distributed under the License is distributed on an "AS IS" BASIS,
19+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20+
* See the License for the specific language governing permissions and
21+
* limitations under the License.
22+
*
23+
* @package GoogleApiAdsAdWords
24+
* @subpackage v201702
25+
* @category WebServices
26+
* @copyright 2016, Google Inc. All Rights Reserved.
27+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License,
28+
* Version 2.0
29+
*/
30+
31+
// Include the initialization file
32+
require_once dirname(dirname(__FILE__)) . '/init.php';
33+
34+
/**
35+
* Runs the example.
36+
* @param AdWordsUser $user the user to run the example with
37+
*/
38+
function GetAccountChangesExample(AdWordsUser $user) {
39+
// Get the service, which loads the required classes.
40+
$campaignService = $user->GetService('CampaignService', ADWORDS_VERSION);
41+
$customerSyncService = $user->GetService('CustomerSyncService', ADWORDS_VERSION);
42+
43+
// Get an array of all campaign ids.
44+
$campaignIds = array();
45+
$selector = new Selector();
46+
$selector->fields = array('Id');
47+
$selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE);
48+
do {
49+
$page = $campaignService->get($selector);
50+
if (isset($page->entries)) {
51+
foreach ($page->entries as $campaign) {
52+
$campaignIds[] = $campaign->id;
53+
}
54+
}
55+
$selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE;
56+
} while ($page->totalNumEntries > $selector->paging->startIndex);
57+
58+
// Set the date time range, from 24 hours ago until now.
59+
$dateTimeRange = new DateTimeRange();
60+
$dateTimeRange->min = date('Ymd his', strtotime('-1 day'));
61+
$dateTimeRange->max = date('Ymd his');
62+
63+
// Create selector.
64+
$selector = new CustomerSyncSelector();
65+
$selector->dateTimeRange = $dateTimeRange;
66+
$selector->campaignIds = $campaignIds;
67+
68+
// Make the get request.
69+
$accountChanges = $customerSyncService->get($selector);
70+
71+
// Display results.
72+
if (isset($accountChanges)) {
73+
printf("Most recent change: %s\n", $accountChanges->lastChangeTimestamp);
74+
if (isset($accountChanges->changedCampaigns)) {
75+
foreach ($accountChanges->changedCampaigns as $campaignChangeData) {
76+
printf("Campaign with id '%.0f' has change status '%s'.\n",
77+
$campaignChangeData->campaignId,
78+
$campaignChangeData->campaignChangeStatus);
79+
if ($campaignChangeData->campaignChangeStatus != 'NEW') {
80+
printf("\tAdded campaign criteria: %s\n",
81+
ArrayToString($campaignChangeData->addedCampaignCriteria));
82+
printf("\tRemoved campaign criteria: %s\n",
83+
ArrayToString($campaignChangeData->removedCampaignCriteria));
84+
if (isset($campaignChangeData->changedAdGroups)) {
85+
foreach($campaignChangeData->changedAdGroups as
86+
$adGroupChangeData) {
87+
printf("\tAd Group with id '%.0f' has change status '%s'.\n",
88+
$adGroupChangeData->adGroupId,
89+
$adGroupChangeData->adGroupChangeStatus);
90+
if ($adGroupChangeData->adGroupChangeStatus != 'NEW') {
91+
printf("\t\tChanged ads: %s\n",
92+
ArrayToString($adGroupChangeData->changedAds));
93+
printf("\t\tChanged criteria: %s\n",
94+
ArrayToString($adGroupChangeData->changedCriteria));
95+
printf("\t\tRemoved criteria: %s\n",
96+
ArrayToString($adGroupChangeData->removedCriteria));
97+
}
98+
}
99+
}
100+
}
101+
}
102+
}
103+
} else {
104+
print "No changes were found.\n";
105+
}
106+
}
107+
108+
/**
109+
* Converts an array of values to a comma-separated string.
110+
* @param array $array an array of values that can be converted to a string
111+
* @return string a comma-separated string of the values
112+
*/
113+
function ArrayToString($array) {
114+
if (!isset($array)) {
115+
return '';
116+
} else {
117+
return implode(', ', $array);
118+
}
119+
}
120+
121+
// Don't run the example if the file is being included.
122+
if (__FILE__ != realpath($_SERVER['PHP_SELF'])) {
123+
return;
124+
}
125+
126+
try {
127+
// Get AdWordsUser from credentials in "../auth.ini"
128+
// relative to the AdWordsUser.php file's directory.
129+
$user = new AdWordsUser();
130+
131+
// Log every SOAP XML request and response.
132+
$user->LogAll();
133+
134+
// Run the example.
135+
GetAccountChangesExample($user);
136+
} catch (Exception $e) {
137+
printf("An error has occurred: %s\n", $e->getMessage());
138+
}

0 commit comments

Comments
 (0)