google ads account账号添加后默认控制绑定只能10个

This commit is contained in:
huangguancheng 2025-02-10 17:44:55 +08:00
parent 13107526fe
commit 505eff067a

View File

@ -90,6 +90,9 @@ class GoogleAdsCustomers
$option = []; $option = [];
$option['refresh_token'] = $thirdUser->access_token; $option['refresh_token'] = $thirdUser->access_token;
$listAccessibleCustomers = $this->googleAdsAccountService->runListAccessibleCustomers($option); $listAccessibleCustomers = $this->googleAdsAccountService->runListAccessibleCustomers($option);
// Add a counter to limit the number of executions
$executionCount = 0;
foreach ($listAccessibleCustomers as $rootAccountId) { foreach ($listAccessibleCustomers as $rootAccountId) {
$option['manager_customer_id'] = $rootAccountId; //开发者 $option['manager_customer_id'] = $rootAccountId; //开发者
$option['login_customer_id'] = $rootAccountId; $option['login_customer_id'] = $rootAccountId;
@ -99,6 +102,12 @@ class GoogleAdsCustomers
// dump($allAccountsByRoot,333); // dump($allAccountsByRoot,333);
foreach ($allAccountsByRoot as $rootId => $accounts) { foreach ($allAccountsByRoot as $rootId => $accounts) {
foreach ($accounts as $account) { foreach ($accounts as $account) {
// Ensure we only execute 10 times
if ($executionCount >= 10) {
dump('Executed 10 times, stopping further calls.');
break 3; // Break out of both inner and outer loops
}
// dump($account);
$this->googleOAuthService->saveThirdUserAdvertiser( $this->googleOAuthService->saveThirdUserAdvertiser(
$account['customer_id'], $account['customer_id'],
$thirdUser->id, $thirdUser->id,
@ -106,6 +115,8 @@ class GoogleAdsCustomers
$account, $account,
$thirdUser->merchant_id $thirdUser->merchant_id
); );
// Increment the counter
$executionCount++;
} }
} }
// 绑定的授权主体全部账号更新后将状态从 'f' 更新为 't' // 绑定的授权主体全部账号更新后将状态从 'f' 更新为 't'