Hi,
We used the following code for V11 and it ran perfectly,
<?php
namespace Google\Ads\GoogleAds\Examples\AccountManagement;
require __DIR__ . '/vendor/autoload.php';
use GetOpt\GetOpt;
use Google\Ads\GoogleAds\Examples\Utils\ArgumentNames;
use Google\Ads\GoogleAds\Examples\Utils\ArgumentParser;
use Google\Ads\GoogleAds\Lib\OAuth2TokenBuilder;
use Google\Ads\GoogleAds\Lib\V13\GoogleAdsClient;
use Google\Ads\GoogleAds\Lib\V13\GoogleAdsClientBuilder;
use Google\Ads\GoogleAds\Lib\V13\GoogleAdsException;
use Google\Ads\GoogleAds\Util\FieldMasks;
use Google\Ads\GoogleAds\Util\V13\ResourceNames;
use Google\Ads\GoogleAds\V13\Enums\ManagerLinkStatusEnum\ManagerLinkStatus;
use Google\Ads\GoogleAds\V13\Errors\GoogleAdsError;
use Google\Ads\GoogleAds\V13\Resources\CustomerClientLink;
use Google\Ads\GoogleAds\V13\Resources\CustomerManagerLink;
use Google\Ads\GoogleAds\V13\Services\CustomerClientLinkOperation;
use Google\Ads\GoogleAds\V13\Services\CustomerManagerLinkOperation;
use Google\ApiCore\ApiException;
try { $oAuth2Credential = (new OAuth2TokenBuilder())->fromFile()->build();
$googleAdsClient = (new GoogleAdsClientBuilder())->fromFile()->withOAuth2Credential($oAuth2Credential)->build();
$customerClientLink = new CustomerClientLink([
'client_customer' => ResourceNames::forCustomer($this_customerId),
'status' => ManagerLinkStatus::UNSPECIFIED
]);
$customerClientLinkOperation = new CustomerClientLinkOperation();
$customerClientLinkOperation->setCreate($customerClientLink);
$customerClientLinkServiceClient = $googleAdsClient->getCustomerClientLinkServiceClient();
try {
$response = $customerClientLinkServiceClient->mutateCustomerClientLink(MANAGER_CUSTOMER_ID, $customerClientLinkOperation);
$customerClientLinkResourceName = $response->getResult()->getResourceName();
} catch (GoogleAdsException $e) {
printf(
"Request with ID '%s' has failed.%sGoogle Ads failure details:%s",
$e->getRequestId(),
PHP_EOL,
PHP_EOL
);
foreach ($e->getGoogleAdsFailure()->getErrors() as $error) {
/** @var GoogleAdsError $error */
printf(
"\t%s: %s%s",
$error->getErrorCode()->getErrorCode(),
$error->getMessage(),
PHP_EOL
);
}
}
} catch (ApiException $e) {
printf(
"ApiException was thrown with message '%s'.%s",
$e->getMessage(),
PHP_EOL
);
print_r($e);
}
And now we are in a process of upgrading it to V13 and its throwing the following error, can anyone help?
Google\ApiCore\ApiException Object
(
[status:Google\ApiCore\ApiException:private] => INVALID_ARGUMENT
[metadata:Google\ApiCore\ApiException:private] => Array
(
[0] => Array
(
[@type] => type.googleapis.com/google.ads.googleads.v13.errors.GoogleAdsFailure
[errors] => Array
(
[0] => Array
(
[errorCode] => Array
(
[managerLinkError] => INVALID_STATUS_CHANGE
)
[message] => The changed status for mutate link is invalid.
[location] => Array
(
[fieldPathElements] => Array
(
[0] => Array
(
[fieldName] => operation
)
)
)
)
)
[requestId] => zqj75KZrVSirR4Vm3FyNAw
)
)
Thanks