googleads / google-ads-php

Google Ads API Client Library for PHP
https://developers.google.com/google-ads/api/docs/client-libs/php
Apache License 2.0
294 stars 262 forks source link

Ending the active account budget issue #875

Closed AlexRyabikov closed 1 year ago

AlexRyabikov commented 1 year ago

Hi!

I've enabled logger in configuration file but it doesnt work in this case (and works with all library examples), or my script does not send the request.

Here is my code, that based on example "add budget proposal" and https://developers.google.com/google-ads/api/docs/billing/account-budgets?hl=en#end code from docs.

<?php

namespace Google\Ads\GoogleAds\Examples\Billing;

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\V12\GoogleAdsClient; use Google\Ads\GoogleAds\Lib\V12\GoogleAdsClientBuilder; use Google\Ads\GoogleAds\Lib\V12\GoogleAdsException; use Google\Ads\GoogleAds\Util\V12\ResourceNames; use Google\Ads\GoogleAds\V12\Enums\AccountBudgetProposalTypeEnum\AccountBudgetProposalType; use Google\Ads\GoogleAds\V12\Enums\TimeTypeEnum\TimeType; use Google\Ads\GoogleAds\V12\Errors\GoogleAdsError; use Google\Ads\GoogleAds\V12\Resources\AccountBudgetProposal; use Google\Ads\GoogleAds\V12\Services\AccountBudgetProposalOperation; use Google\ApiCore\ApiException;

/**

$accountBudgetProposal = new AccountBudgetProposal([ 'billing_setup' => ResourceNames::forBillingSetup($customerId, $billingSetupId), 'proposal_type' => AccountBudgetProposalType::END, 'account_budget' => 'customers/3721199407/accountBudgets/6885650342' ]); $accountBudgetProposalOperation = new AccountBudgetProposalOperation(); $accountBudgetProposalOperation->setCreate($accountBudgetProposal);

}
// [END add_account_budget_proposal]

}

AddAccountBudgetProposal::main();

?>

I'm sure, that I did something wrong, but idk what could be wrong

Can you help me please?

fiboknacky commented 1 year ago

Can you try the steps to run code examples? Would that return anything?

AlexRyabikov commented 1 year ago

Hi! Yes, examples are working, and some other scripts based on examples are OK (account management for example).

I have a problem with updating account budget proposal. And guys from google ads api forum sent me here.

In my previous something wrong with my code, sorry. Here is normal version:

Logger and script doesnt return anything

UpdBudg.txt

fiboknacky commented 1 year ago

When you say it's not sending a request, what happened? Nothing is shown? Usually, they should be some logs on screen even if you do something wrong. Is it possible for you to turn off logging so it show the result on screen instead?

AlexRyabikov commented 1 year ago

Yep, you right, nothing is shown. It had returned some errors in case when I forgot to add some parts of library (use Google\Ads\GoogleAds\Util\FieldMasks, for example), but now just nothing: no logs, no errors. I have no idea why, unfortunately.

About line to fix (setCreate) - it's strange, because Google use it in this example: https://developers.google.com/google-ads/api/docs/billing/account-budgets?hl=en#php

Also on screenshot in attache: KrvXYVjD

fiboknacky commented 1 year ago

Sorry. It's an account budget proposal, so using setCreate is already fine. The reason why there is nothing shown is that you've not sent your request yet. You have to use AccountBudgetProposalServiceClient to send your request just like you do when adding a new account budget proposal

AlexRyabikov commented 1 year ago

Hi! Yes, you were right :) Problem solved. Thnx for help :)