Skip to content

Commit

Permalink
Release 28.1.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
Thang Duong committed Aug 10, 2017
1 parent 8eaac76 commit 17cf803
Show file tree
Hide file tree
Showing 1,101 changed files with 81,369 additions and 87 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
### 28.1.0

##### AdWords

* Added support and examples for v201708.
* Fixed
[issue #331](https://github.com/googleads/googleads-php-lib/issues/331).

##### Common

* Added a getter for SOAP response header values and SOAP fault message.

### 28.0.0

##### AdWords
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"symfony/serializer": "^2.8.0 || ^3.0.3"
},
"require-dev": {
"php": ">=5.5.17",
"phpunit/phpunit": "^4.8"
},
"suggest": {
Expand Down
15 changes: 10 additions & 5 deletions examples/AdWords/v201609/AccountManagement/GetAccountHierarchy.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,17 @@ public static function runExample(AdWordsServices $adWordsServices,
$totalNumEntries = $page->getTotalNumEntries();
if ($page->getLinks() !== null) {
foreach ($page->getLinks() as $link) {
$customerIdsToChildLinks[$link->getManagerCustomerId()][] = $link;
$customerIdsToParentLinks[$link->getClientCustomerId()] = $link;
// Cast the indexes to string to avoid the issue when 32-bit PHP
// automatically changes the IDs that are larger than the 32-bit max
// integer value to negative numbers.
$managerCustomerId = strval($link->getManagerCustomerId());
$customerIdsToChildLinks[$managerCustomerId][] = $link;
$clientCustomerId = strval($link->getClientCustomerId());
$customerIdsToParentLinks[$clientCustomerId] = $link;
}
}
foreach ($page->getEntries() as $account) {
$customerIdsToAccounts[$account->getCustomerId()] = $account;
$customerIdsToAccounts[strval($account->getCustomerId())] = $account;
}
}

Expand Down Expand Up @@ -118,9 +123,9 @@ private static function printAccountHierarchy($account,
printf("%s, %s\n", $customerId, $account->getName());

if (array_key_exists($customerId, $customerIdsToChildLinks)) {
foreach ($customerIdsToChildLinks[$customerId] as $childLink) {
foreach ($customerIdsToChildLinks[strval($customerId)] as $childLink) {
$childAccount =
$customerIdsToAccounts[$childLink->getClientCustomerId()];
$customerIdsToAccounts[strval($childLink->getClientCustomerId())];
self::printAccountHierarchy($childAccount, $customerIdsToAccounts,
$customerIdsToChildLinks, $depth + 1);
}
Expand Down
2 changes: 1 addition & 1 deletion examples/AdWords/v201609/Misc/UploadImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static function runExample(AdWordsServices $adWordsServices,

// Create an image and add it to the images list.
$image = new Image();
$image->setData(file_get_contents('http://goo.gl/HJM3L'));
$image->setData(file_get_contents('https://goo.gl/3b9Wfh'));
$image->setType(MediaMediaType::IMAGE);
$images = [$image];

Expand Down
21 changes: 10 additions & 11 deletions examples/AdWords/v201609/Reporting/ParallelReportDownload.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,15 @@ public static function runExample(AdWordsServices $adWordsServices,
do {
$retryCount++;
try {
$reportDownloadResult =
$reportDownloader->downloadReport($reportDefinition);
// Optional: If you need to adjust report settings just for this one
// request, you can create and supply the settings override here.
// Otherwise, default values from the configuration file
// (adsapi_php.ini) are used.
$reportSettingsOverride = (new ReportSettingsBuilder())
->includeZeroImpressions(false)
->build();
$reportDownloadResult = $reportDownloader->downloadReport(
$reportDefinition, $reportSettingsOverride);
$reportDownloadResult->saveToFile($filePath);
printf(
"Report for client customer ID %d successfully downloaded to: "
Expand Down Expand Up @@ -192,19 +199,11 @@ public static function main() {
->fromFile()
->build();

// See: ReportSettingsBuilder for more options (e.g., suppress headers)
// or set them in your adsapi_php.ini file.
$reportSettings = (new ReportSettingsBuilder())
->fromFile()
->includeZeroImpressions(false)
->build();

// See: AdWordsSessionBuilder for setting a client customer ID that is
// different from that specified in your adsapi_php.ini file.
$sessionBuilder = (new AdWordsSessionBuilder())
->fromFile()
->withOAuth2Credential($oAuth2Credential)
->withReportSettings($reportSettings);
->withOAuth2Credential($oAuth2Credential);

self::runExample(new AdWordsServices(), $sessionBuilder,
sys_get_temp_dir());
Expand Down
15 changes: 10 additions & 5 deletions examples/AdWords/v201702/AccountManagement/GetAccountHierarchy.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,17 @@ public static function runExample(AdWordsServices $adWordsServices,
$totalNumEntries = $page->getTotalNumEntries();
if ($page->getLinks() !== null) {
foreach ($page->getLinks() as $link) {
$customerIdsToChildLinks[$link->getManagerCustomerId()][] = $link;
$customerIdsToParentLinks[$link->getClientCustomerId()] = $link;
// Cast the indexes to string to avoid the issue when 32-bit PHP
// automatically changes the IDs that are larger than the 32-bit max
// integer value to negative numbers.
$managerCustomerId = strval($link->getManagerCustomerId());
$customerIdsToChildLinks[$managerCustomerId][] = $link;
$clientCustomerId = strval($link->getClientCustomerId());
$customerIdsToParentLinks[$clientCustomerId] = $link;
}
}
foreach ($page->getEntries() as $account) {
$customerIdsToAccounts[$account->getCustomerId()] = $account;
$customerIdsToAccounts[strval($account->getCustomerId())] = $account;
}
}

Expand Down Expand Up @@ -118,9 +123,9 @@ private static function printAccountHierarchy($account,
printf("%s, %s\n", $customerId, $account->getName());

if (array_key_exists($customerId, $customerIdsToChildLinks)) {
foreach ($customerIdsToChildLinks[$customerId] as $childLink) {
foreach ($customerIdsToChildLinks[strval($customerId)] as $childLink) {
$childAccount =
$customerIdsToAccounts[$childLink->getClientCustomerId()];
$customerIdsToAccounts[strval($childLink->getClientCustomerId())];
self::printAccountHierarchy($childAccount, $customerIdsToAccounts,
$customerIdsToChildLinks, $depth + 1);
}
Expand Down
2 changes: 1 addition & 1 deletion examples/AdWords/v201702/Misc/UploadImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static function runExample(AdWordsServices $adWordsServices,

// Create an image and add it to the images list.
$image = new Image();
$image->setData(file_get_contents('http://goo.gl/HJM3L'));
$image->setData(file_get_contents('https://goo.gl/3b9Wfh'));
$image->setType(MediaMediaType::IMAGE);
$images = [$image];

Expand Down
21 changes: 10 additions & 11 deletions examples/AdWords/v201702/Reporting/ParallelReportDownload.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,15 @@ public static function runExample(AdWordsServices $adWordsServices,
do {
$retryCount++;
try {
$reportDownloadResult =
$reportDownloader->downloadReport($reportDefinition);
// Optional: If you need to adjust report settings just for this one
// request, you can create and supply the settings override here.
// Otherwise, default values from the configuration file
// (adsapi_php.ini) are used.
$reportSettingsOverride = (new ReportSettingsBuilder())
->includeZeroImpressions(false)
->build();
$reportDownloadResult = $reportDownloader->downloadReport(
$reportDefinition, $reportSettingsOverride);
$reportDownloadResult->saveToFile($filePath);
printf(
"Report for client customer ID %d successfully downloaded to: "
Expand Down Expand Up @@ -192,19 +199,11 @@ public static function main() {
->fromFile()
->build();

// See: ReportSettingsBuilder for more options (e.g., suppress headers)
// or set them in your adsapi_php.ini file.
$reportSettings = (new ReportSettingsBuilder())
->fromFile()
->includeZeroImpressions(false)
->build();

// See: AdWordsSessionBuilder for setting a client customer ID that is
// different from that specified in your adsapi_php.ini file.
$sessionBuilder = (new AdWordsSessionBuilder())
->fromFile()
->withOAuth2Credential($oAuth2Credential)
->withReportSettings($reportSettings);
->withOAuth2Credential($oAuth2Credential);

self::runExample(new AdWordsServices(), $sessionBuilder,
sys_get_temp_dir());
Expand Down
15 changes: 10 additions & 5 deletions examples/AdWords/v201705/AccountManagement/GetAccountHierarchy.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,17 @@ public static function runExample(AdWordsServices $adWordsServices,
$totalNumEntries = $page->getTotalNumEntries();
if ($page->getLinks() !== null) {
foreach ($page->getLinks() as $link) {
$customerIdsToChildLinks[$link->getManagerCustomerId()][] = $link;
$customerIdsToParentLinks[$link->getClientCustomerId()] = $link;
// Cast the indexes to string to avoid the issue when 32-bit PHP
// automatically changes the IDs that are larger than the 32-bit max
// integer value to negative numbers.
$managerCustomerId = strval($link->getManagerCustomerId());
$customerIdsToChildLinks[$managerCustomerId][] = $link;
$clientCustomerId = strval($link->getClientCustomerId());
$customerIdsToParentLinks[$clientCustomerId] = $link;
}
}
foreach ($page->getEntries() as $account) {
$customerIdsToAccounts[$account->getCustomerId()] = $account;
$customerIdsToAccounts[strval($account->getCustomerId())] = $account;
}
}

Expand Down Expand Up @@ -118,9 +123,9 @@ private static function printAccountHierarchy($account,
printf("%s, %s\n", $customerId, $account->getName());

if (array_key_exists($customerId, $customerIdsToChildLinks)) {
foreach ($customerIdsToChildLinks[$customerId] as $childLink) {
foreach ($customerIdsToChildLinks[strval($customerId)] as $childLink) {
$childAccount =
$customerIdsToAccounts[$childLink->getClientCustomerId()];
$customerIdsToAccounts[strval($childLink->getClientCustomerId())];
self::printAccountHierarchy($childAccount, $customerIdsToAccounts,
$customerIdsToChildLinks, $depth + 1);
}
Expand Down
2 changes: 1 addition & 1 deletion examples/AdWords/v201705/Misc/UploadImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static function runExample(AdWordsServices $adWordsServices,

// Create an image and add it to the images list.
$image = new Image();
$image->setData(file_get_contents('http://goo.gl/HJM3L'));
$image->setData(file_get_contents('https://goo.gl/3b9Wfh'));
$image->setType(MediaMediaType::IMAGE);
$images = [$image];

Expand Down
21 changes: 10 additions & 11 deletions examples/AdWords/v201705/Reporting/ParallelReportDownload.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,15 @@ public static function runExample(AdWordsServices $adWordsServices,
do {
$retryCount++;
try {
$reportDownloadResult =
$reportDownloader->downloadReport($reportDefinition);
// Optional: If you need to adjust report settings just for this one
// request, you can create and supply the settings override here.
// Otherwise, default values from the configuration file
// (adsapi_php.ini) are used.
$reportSettingsOverride = (new ReportSettingsBuilder())
->includeZeroImpressions(false)
->build();
$reportDownloadResult = $reportDownloader->downloadReport(
$reportDefinition, $reportSettingsOverride);
$reportDownloadResult->saveToFile($filePath);
printf(
"Report for client customer ID %d successfully downloaded to: "
Expand Down Expand Up @@ -192,19 +199,11 @@ public static function main() {
->fromFile()
->build();

// See: ReportSettingsBuilder for more options (e.g., suppress headers)
// or set them in your adsapi_php.ini file.
$reportSettings = (new ReportSettingsBuilder())
->fromFile()
->includeZeroImpressions(false)
->build();

// See: AdWordsSessionBuilder for setting a client customer ID that is
// different from that specified in your adsapi_php.ini file.
$sessionBuilder = (new AdWordsSessionBuilder())
->fromFile()
->withOAuth2Credential($oAuth2Credential)
->withReportSettings($reportSettings);
->withOAuth2Credential($oAuth2Credential);

self::runExample(new AdWordsServices(), $sessionBuilder,
sys_get_temp_dir());
Expand Down
88 changes: 88 additions & 0 deletions examples/AdWords/v201708/AccountManagement/AcceptServiceLink.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php
/**
* Copyright 2017 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace Google\AdsApi\Examples\AdWords\v201708\AccountManagement;

require __DIR__ . '/../../../../vendor/autoload.php';

use Google\AdsApi\AdWords\AdWordsServices;
use Google\AdsApi\AdWords\AdWordsSession;
use Google\AdsApi\AdWords\AdWordsSessionBuilder;
use Google\AdsApi\AdWords\v201708\cm\Operator;
use Google\AdsApi\AdWords\v201708\mcm\CustomerService;
use Google\AdsApi\AdWords\v201708\mcm\ServiceLink;
use Google\AdsApi\AdWords\v201708\mcm\ServiceLinkLinkStatus;
use Google\AdsApi\AdWords\v201708\mcm\ServiceLinkOperation;
use Google\AdsApi\AdWords\v201708\mcm\ServiceType;
use Google\AdsApi\Common\OAuth2TokenBuilder;

/**
* This example accepts a pending invitation to link your AdWords account to a
* Google Merchant Center account.
*/
class AcceptServiceLink {

const SERVICE_LINK_ID = 'INSERT_SERVICE_LINK_ID_HERE';

public static function runExample(AdWordsServices $adWordsServices,
AdWordsSession $session, $serviceLinkId) {
$customerService = $adWordsServices->get($session, CustomerService::class);

// Create service link.
$serviceLink = new ServiceLink();
$serviceLink->setServiceLinkId($serviceLinkId);
$serviceLink->setServiceType(ServiceType::MERCHANT_CENTER);
$serviceLink->setLinkStatus(ServiceLinkLinkStatus::ACTIVE);

// Create a service link operation and add it to the list.
$operations = [];
$operation = new ServiceLinkOperation();
$operation->setOperator(Operator::SET);
$operation->setOperand($serviceLink);
$operations[] = $operation;

// Accept service links on the server and print out some information about
// accepted service links.
$serviceLinks = $customerService->mutateServiceLinks($operations);
foreach ($serviceLinks as $serviceLink) {
printf(
"Service link with service link ID %d and type '%s' updated to status"
. ": %s.\n",
$serviceLink->getServiceLinkId(),
$serviceLink->getServiceType(),
$serviceLink->getLinkStatus()
);
}
}

public static function main() {
// Generate a refreshable OAuth2 credential for authentication.
$oAuth2Credential = (new OAuth2TokenBuilder())
->fromFile()
->build();

// Construct an API session configured from a properties file and the OAuth2
// credentials above.
$session = (new AdWordsSessionBuilder())
->fromFile()
->withOAuth2Credential($oAuth2Credential)
->build();
self::runExample(
new AdWordsServices(), $session, intval(self::SERVICE_LINK_ID));
}
}

AcceptServiceLink::main();
Loading

0 comments on commit 17cf803

Please sign in to comment.