Hi!
I implement AccountBudgetProposal instead to BudgetOrder in Adword API cause migrate to Ads API.
However, when I execute to AccountBudgetProposal then I get some error.
Below message is my error message.
{
"message": "Request contains an invalid argument.",
"code": 3,
"status": "INVALID_ARGUMENT",
"details": [
{
"@type": "google.ads.googleads.v10.errors.googleadsfailure-bin",
"data": "<Unknown Binary Data>"
},
{
"@type": "grpc-status-details-bin",
"data": "<Unknown Binary Data>"
},
{
"@type": "request-id",
"data": "htxpogqxiz1oNVAxrA-9aA"
}
]
}
Below code is my implementation code.
private static function getBillingSetupID(GoogleAdsClient $googleAdsClient, $data)
{
$googleAdsServiceClient = $googleAdsClient->getGoogleAdsServiceClient();
$query = 'SELECT billing_setup.id, billing_setup.status, billing_setup.payments_account_info.payments_account_id, billing_setup.payments_account_info.payments_account_name, billing_setup.payments_account_info.payments_profile_id, billing_setup.payments_account_info.payments_profile_name, billing_setup.payments_account_info.secondary_payments_profile_id FROM billing_setup';
$response = $googleAdsServiceClient->search($data["clientCustomerID"], $query);
foreach ($response->iterateAllElements() as $googleAdsRow) {
$paymentAccountInfo = $googleAdsRow->getBillingSetup()->getPaymentsAccountInfo();
if (is_null($paymentAccountInfo)) {
continue;
}
return $googleAdsRow->getBillingSetup()->getId();
}
}
private static function createBudgetOrder(GoogleAdsClient $googleAdsClient, $data)
{
$accountBudgetProposal = new AccountBudgetProposal([
'billing_setup' => ResourceNames::forBillingSetup($data["clientCustomerID"], self::getBillingSetupID($googleAdsClient, $data)),
'proposal_type' => AccountBudgetProposalType::CREATE,
'proposed_start_time_type' => TimeType::NOW,
'proposed_end_time_type' => TimeType::FOREVER,
'proposed_spending_limit_micros' => $data["amount"]*1000000
]);
$accountBudgetProposalOperation = new AccountBudgetProposalOperation();
$accountBudgetProposalOperation->setCreate($accountBudgetProposal);
$accountBudgetProposalServiceClient = $googleAdsClient->getAccountBudgetProposalServiceClient();
$response = $accountBudgetProposalServiceClient->mutateAccountBudgetProposal(
$data["clientCustomerID"],
$accountBudgetProposalOperation
);
return $response->getResult();
}
public static function main($action, $data)
{
$oAuth2Credential = (new OAuth2TokenBuilder())->withClientId(config('AdsConfig')->CLIENT_ID)->withClientSecret(config('AdsConfig')->CLIENT_SECRET)->withRefreshToken(config('AdsConfig')->REFRESH_TOKEN)->build();
$googleAdsClient = (new GoogleAdsClientBuilder())->withDeveloperToken(config('AdsConfig')->DEVELOPER_TOKEN)->withOAuth2Credential($oAuth2Credential)->withLoginCustomerId(config('AdsConfig')->CLIENT_CUSTOMER_ID)->build();
return self::{$action}($googleAdsClient, $data);
}
Below values are using each variables in above codes.
$action = "createBudgetOrder";
$data["clientCustomerID"] = "6357610105";
$data["amount"] = 5000;
returned value is 6733533069 from self::getBillingSetupID function.
That error appeared at mutateAccountBudgetProposal function.
Please let me know, how to solve that error.
Best regards.