Hi!
Sorry for delay.
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.
<?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;
/**
* This example creates an account budget proposal using the 'CREATE' operation. To get account
* budget proposals, run GetAccountBudgetProposals.php
*/
class AddAccountBudgetProposal
{
private const CUSTOMER_ID = '3721199407';
private const BILLING_SETUP_ID = '6885573946';
public static function main()
{
// Either pass the required parameters for this example on the command line, or insert them
// into the constants above.
$options = (new ArgumentParser())->parseCommandArguments([
ArgumentNames::CUSTOMER_ID => GetOpt::REQUIRED_ARGUMENT,
ArgumentNames::BILLING_SETUP_ID => GetOpt::REQUIRED_ARGUMENT
]);
// Generate a refreshable OAuth2 credential for authentication.
$oAuth2Credential = (new OAuth2TokenBuilder())->fromFile()->build();
// Construct a Google Ads client configured from a properties file and the
// OAuth2 credentials above.
$googleAdsClient = (new GoogleAdsClientBuilder())->fromFile()
->withOAuth2Credential($oAuth2Credential)
->build();
try {
self::runExample(
$googleAdsClient,
$options[ArgumentNames::CUSTOMER_ID] ?: self::CUSTOMER_ID,
$options[ArgumentNames::BILLING_SETUP_ID] ?: self::BILLING_SETUP_ID
);
} catch (GoogleAdsException $googleAdsException) {
printf(
"Request with ID '%s' has failed.%sGoogle Ads failure details:%s",
$googleAdsException->getRequestId(),
PHP_EOL,
PHP_EOL
);
foreach ($googleAdsException->getGoogleAdsFailure()->getErrors() as $error) {
/** @var GoogleAdsError $error */
printf(
"\t%s: %s%s",
$error->getErrorCode()->getErrorCode(),
$error->getMessage(),
PHP_EOL
);
}
exit(1);
} catch (ApiException $apiException) {
printf(
"ApiException was thrown with message '%s'.%s",
$apiException->getMessage(),
PHP_EOL
);
exit(1);
}
}
/**
* Runs the example.
*
* @param GoogleAdsClient $googleAdsClient the Google Ads API client
* @param int $customerId the customer ID
* @param int $billingSetupId the billing setup ID used to add the account budget proposal
*/
// [START add_account_budget_proposal]
public static function runExample(
GoogleAdsClient $googleAdsClient,
int $customerId,
int $billingSetupId
) {
// Constructs an account budget proposal.
$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?
среда, 1 февраля 2023 г. в 18:37:37 UTC+3, Алексей Рябиков: