Skip to content

Commit 4058cd3

Browse files
author
Ray Tsang
committed
Preparing src for release 5.5.2
1 parent aded895 commit 4058cd3

File tree

270 files changed

+229109
-8266
lines changed

Some content is hidden

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

270 files changed

+229109
-8266
lines changed

ChangeLog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
### 5.5.2
2+
3+
AdWords:
4+
- Added v201409 support.
5+
16
### 5.5.1
27

38
AdWords:

examples/AdWords/v201402/BasicOperations/AddCampaigns.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php
1+
<?php
22
/**
33
* This example adds campaigns.
44
*

examples/AdWords/v201406/BasicOperations/AddCampaigns.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php
1+
<?php
22
/**
33
* This example adds campaigns.
44
*
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?php
2+
/**
3+
* This example creates a new account under an MCC account. Note: this example
4+
* must be run using the credentials of an MCC account, and by default the new
5+
* account will only be accessible via the parent MCC account.
6+
*
7+
* Tags: ManagedCustomerService.mutate
8+
* Restriction: adwords-only
9+
*
10+
* PHP version 5
11+
*
12+
* Copyright 2014, Google Inc. All Rights Reserved.
13+
*
14+
* Licensed under the Apache License, Version 2.0 (the "License");
15+
* you may not use this file except in compliance with the License.
16+
* You may obtain a copy of the License at
17+
*
18+
* http://www.apache.org/licenses/LICENSE-2.0
19+
*
20+
* Unless required by applicable law or agreed to in writing, software
21+
* distributed under the License is distributed on an "AS IS" BASIS,
22+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23+
* See the License for the specific language governing permissions and
24+
* limitations under the License.
25+
*
26+
* @package GoogleApiAdsAdWords
27+
* @subpackage v201409
28+
* @category WebServices
29+
* @copyright 2014, Google Inc. All Rights Reserved.
30+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License,
31+
* Version 2.0
32+
* @author Eric Koleda
33+
*/
34+
35+
// Include the initialization file
36+
require_once dirname(dirname(__FILE__)) . '/init.php';
37+
38+
/**
39+
* Runs the example.
40+
* @param AdWordsUser $user the user to run the example with
41+
*/
42+
function CreateAccountExample(AdWordsUser $user) {
43+
// Get the service, which loads the required classes.
44+
$managedCustomerService =
45+
$user->GetService('ManagedCustomerService', ADWORDS_VERSION);
46+
47+
// Create customer.
48+
$customer = new ManagedCustomer();
49+
$customer->name = 'Account #' . uniqid();
50+
$customer->currencyCode = 'EUR';
51+
$customer->dateTimeZone = 'Europe/London';
52+
53+
// Create operation.
54+
$operation = new ManagedCustomerOperation();
55+
$operation->operator = 'ADD';
56+
$operation->operand = $customer;
57+
58+
$operations = array($operation);
59+
60+
// Make the mutate request.
61+
$result = $managedCustomerService->mutate($operations);
62+
63+
// Display result.
64+
$customer = $result->value[0];
65+
printf("Account with customer ID '%s' was created.\n",
66+
$customer->customerId);
67+
}
68+
69+
// Don't run the example if the file is being included.
70+
if (__FILE__ != realpath($_SERVER['PHP_SELF'])) {
71+
return;
72+
}
73+
74+
try {
75+
// Get AdWordsUser from credentials in "../auth.ini"
76+
// relative to the AdWordsUser.php file's directory.
77+
$user = new AdWordsUser();
78+
79+
// Log every SOAP XML request and response.
80+
$user->LogAll();
81+
82+
// Run the example.
83+
CreateAccountExample($user);
84+
} catch (Exception $e) {
85+
printf("An error has occurred: %s\n", $e->getMessage());
86+
}
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
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+
* Tags: CustomerSyncService.get
8+
*
9+
* PHP version 5
10+
*
11+
* Copyright 2014, Google Inc. All Rights Reserved.
12+
*
13+
* Licensed under the Apache License, Version 2.0 (the "License");
14+
* you may not use this file except in compliance with the License.
15+
* You may obtain a copy of the License at
16+
*
17+
* http://www.apache.org/licenses/LICENSE-2.0
18+
*
19+
* Unless required by applicable law or agreed to in writing, software
20+
* distributed under the License is distributed on an "AS IS" BASIS,
21+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22+
* See the License for the specific language governing permissions and
23+
* limitations under the License.
24+
*
25+
* @package GoogleApiAdsAdWords
26+
* @subpackage v201409
27+
* @category WebServices
28+
* @copyright 2014, Google Inc. All Rights Reserved.
29+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License,
30+
* Version 2.0
31+
* @author Eric Koleda
32+
*/
33+
34+
// Include the initialization file
35+
require_once dirname(dirname(__FILE__)) . '/init.php';
36+
37+
/**
38+
* Runs the example.
39+
* @param AdWordsUser $user the user to run the example with
40+
*/
41+
function GetAccountChangesExample(AdWordsUser $user) {
42+
// Get the service, which loads the required classes.
43+
$campaignService = $user->GetService('CampaignService', ADWORDS_VERSION);
44+
$customerSyncService = $user->GetService('CustomerSyncService', ADWORDS_VERSION);
45+
46+
// Get an array of all campaign ids.
47+
$campaignIds = array();
48+
$selector = new Selector();
49+
$selector->fields = array('Id');
50+
$selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE);
51+
do {
52+
$page = $campaignService->get($selector);
53+
if (isset($page->entries)) {
54+
foreach ($page->entries as $campaign) {
55+
$campaignIds[] = $campaign->id;
56+
}
57+
}
58+
$selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE;
59+
} while ($page->totalNumEntries > $selector->paging->startIndex);
60+
61+
// Set the date time range, from 24 hours ago until now.
62+
$dateTimeRange = new DateTimeRange();
63+
$dateTimeRange->min = date('Ymd his', strtotime('-1 day'));
64+
$dateTimeRange->max = date('Ymd his');
65+
66+
// Create selector.
67+
$selector = new CustomerSyncSelector();
68+
$selector->dateTimeRange = $dateTimeRange;
69+
$selector->campaignIds = $campaignIds;
70+
71+
// Make the get request.
72+
$accountChanges = $customerSyncService->get($selector);
73+
74+
// Display results.
75+
if (isset($accountChanges)) {
76+
printf("Most recent change: %s\n", $accountChanges->lastChangeTimestamp);
77+
if (isset($accountChanges->changedCampaigns)) {
78+
foreach ($accountChanges->changedCampaigns as $campaignChangeData) {
79+
printf("Campaign with id '%.0f' has change status '%s'.\n",
80+
$campaignChangeData->campaignId,
81+
$campaignChangeData->campaignChangeStatus);
82+
if ($campaignChangeData->campaignChangeStatus != 'NEW') {
83+
printf("\tAdded ad extensions: %s\n",
84+
ArrayToString($campaignChangeData->addedAdExtensions));
85+
printf("\tDeleted ad extensions: %s\n",
86+
ArrayToString($campaignChangeData->deletedAdExtensions));
87+
printf("\tAdded campaign criteria: %s\n",
88+
ArrayToString($campaignChangeData->addedCampaignCriteria));
89+
printf("\tDeleted campaign criteria: %s\n",
90+
ArrayToString($campaignChangeData->deletedCampaignCriteria));
91+
printf("\tCampaign targeting changed: %s\n",
92+
$campaignChangeData->campaignTargetingChanged ? 'true'
93+
: 'false');
94+
if (isset($campaignChangeData->changedAdGroups)) {
95+
foreach($campaignChangeData->changedAdGroups as
96+
$adGroupChangeData) {
97+
printf("\tAd Group with id '%.0f' has change status '%s'.\n",
98+
$adGroupChangeData->adGroupId,
99+
$adGroupChangeData->adGroupChangeStatus);
100+
if ($adGroupChangeData->adGroupChangeStatus != 'NEW') {
101+
printf("\t\tChanged ads: %s\n",
102+
ArrayToString($adGroupChangeData->changedAds));
103+
printf("\t\tChanged criteria: %s\n",
104+
ArrayToString($adGroupChangeData->changedCriteria));
105+
printf("\t\tDeleted criteria: %s\n",
106+
ArrayToString($adGroupChangeData->deletedCriteria));
107+
}
108+
}
109+
}
110+
}
111+
}
112+
}
113+
} else {
114+
print "No changes were found.\n";
115+
}
116+
}
117+
118+
/**
119+
* Converts an array of values to a comma-separated string.
120+
* @param array $array an array of values that can be converted to a string
121+
* @return string a comma-separated string of the values
122+
*/
123+
function ArrayToString($array) {
124+
if (!isset($array)) {
125+
return '';
126+
} else {
127+
return implode(', ', $array);
128+
}
129+
}
130+
131+
// Don't run the example if the file is being included.
132+
if (__FILE__ != realpath($_SERVER['PHP_SELF'])) {
133+
return;
134+
}
135+
136+
try {
137+
// Get AdWordsUser from credentials in "../auth.ini"
138+
// relative to the AdWordsUser.php file's directory.
139+
$user = new AdWordsUser();
140+
141+
// Log every SOAP XML request and response.
142+
$user->LogAll();
143+
144+
// Run the example.
145+
GetAccountChangesExample($user);
146+
} catch (Exception $e) {
147+
printf("An error has occurred: %s\n", $e->getMessage());
148+
}
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
<?php
2+
/**
3+
* This example gets the account hierarchy under the current account. Note: this
4+
* example must be run using the credentials of an MCC account.
5+
*
6+
* Tags: ManagedCustomerService.get
7+
* Restriction: adwords-only
8+
*
9+
* PHP version 5
10+
*
11+
* Copyright 2014, Google Inc. All Rights Reserved.
12+
*
13+
* Licensed under the Apache License, Version 2.0 (the "License");
14+
* you may not use this file except in compliance with the License.
15+
* You may obtain a copy of the License at
16+
*
17+
* http://www.apache.org/licenses/LICENSE-2.0
18+
*
19+
* Unless required by applicable law or agreed to in writing, software
20+
* distributed under the License is distributed on an "AS IS" BASIS,
21+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22+
* See the License for the specific language governing permissions and
23+
* limitations under the License.
24+
*
25+
* @package GoogleApiAdsAdWords
26+
* @subpackage v201409
27+
* @category WebServices
28+
* @copyright 2014, Google Inc. All Rights Reserved.
29+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License,
30+
* Version 2.0
31+
* @author Eric Koleda
32+
*/
33+
34+
// Include the initialization file
35+
require_once dirname(dirname(__FILE__)) . '/init.php';
36+
37+
/**
38+
* Runs the example.
39+
* @param AdWordsUser $user the user to run the example with
40+
*/
41+
function GetAccountHierarchyExample(AdWordsUser $user) {
42+
// Get the service, which loads the required classes.
43+
$managedCustomerService =
44+
$user->GetService('ManagedCustomerService', ADWORDS_VERSION);
45+
46+
// Create selector.
47+
$selector = new Selector();
48+
// Specify the fields to retrieve.
49+
$selector->fields = array('CustomerId', 'Name');
50+
51+
// Make the get request.
52+
$graph = $managedCustomerService->get($selector);
53+
54+
// Display serviced account graph.
55+
if (isset($graph->entries)) {
56+
// Create map from customerId to parent and child links.
57+
$childLinks = array();
58+
$parentLinks = array();
59+
if (isset($graph->links)) {
60+
foreach ($graph->links as $link) {
61+
$childLinks[$link->managerCustomerId][] = $link;
62+
$parentLinks[$link->clientCustomerId][] = $link;
63+
}
64+
}
65+
// Create map from customerID to account, and find root account.
66+
$accounts = array();
67+
$rootAccount = NULL;
68+
foreach ($graph->entries as $account) {
69+
$accounts[$account->customerId] = $account;
70+
if (!array_key_exists($account->customerId, $parentLinks)) {
71+
$rootAccount = $account;
72+
}
73+
}
74+
// The root account may not be returned in the sandbox.
75+
if (!isset($rootAccount)) {
76+
$rootAccount = new Account();
77+
$rootAccount->customerId = 0;
78+
}
79+
// Display account tree.
80+
print "(Customer Id, Account Name)\n";
81+
DisplayAccountTree($rootAccount, NULL, $accounts, $childLinks, 0);
82+
} else {
83+
print "No serviced accounts were found.\n";
84+
}
85+
}
86+
87+
/**
88+
* Displays an account tree, starting at the account and link provided, and
89+
* recursing to all child accounts.
90+
* @param Account $account the account to display
91+
* @param Link $link the link used to reach this account
92+
* @param array $accounts a map from customerId to account
93+
* @param array $links a map from customerId to child links
94+
* @param int $depth the depth of the current account in the tree
95+
*/
96+
function DisplayAccountTree($account, $link, $accounts, $links, $depth) {
97+
print str_repeat('-', $depth * 2);
98+
printf("%s, %s\n", $account->customerId, $account->name);
99+
if (array_key_exists($account->customerId, $links)) {
100+
foreach ($links[$account->customerId] as $childLink) {
101+
$childAccount = $accounts[$childLink->clientCustomerId];
102+
DisplayAccountTree($childAccount, $childLink, $accounts, $links,
103+
$depth +1);
104+
}
105+
}
106+
}
107+
108+
// Don't run the example if the file is being included.
109+
if (__FILE__ != realpath($_SERVER['PHP_SELF'])) {
110+
return;
111+
}
112+
113+
try {
114+
// Get AdWordsUser from credentials in "../auth.ini"
115+
// relative to the AdWordsUser.php file's directory.
116+
$user = new AdWordsUser();
117+
118+
// Log every SOAP XML request and response.
119+
$user->LogAll();
120+
121+
// Run the example.
122+
GetAccountHierarchyExample($user);
123+
} catch (Exception $e) {
124+
printf("An error has occurred: %s\n", $e->getMessage());
125+
}

0 commit comments

Comments
 (0)