Skip to content

Commit e167f4d

Browse files
authored
Merge pull request #76 from BingAds/samples-update
searchaccountsbyuserid params
2 parents ad692d7 + 723a786 commit e167f4d

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

samples/V12/AuthHelper.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,24 +81,27 @@ static function Authenticate()
8181
AuthHelper::GetApiEnvironment());
8282

8383
// Set to an empty user identifier to get the current authenticated Bing Ads user,
84-
// and then search for all accounts the user may access.
84+
// and then search for accounts the user can access.
8585
$user = CustomerManagementExampleHelper::GetUser(null, true)->User;
86-
$accounts = AuthHelper::SearchAccountsByUserId($user->Id)->Accounts;
86+
87+
// To retrieve more than 100 accounts, increase the page size up to 1,000.
88+
// To retrieve more than 1,000 accounts you'll need to implement paging.
89+
$accounts = AuthHelper::SearchAccountsByUserId($user->Id, 0, 100)->Accounts;
8790

8891
// For this example we'll use the first account.
8992
$GLOBALS['AuthorizationData']->AccountId = $accounts->AdvertiserAccount[0]->Id;
9093
$GLOBALS['AuthorizationData']->CustomerId = $accounts->AdvertiserAccount[0]->ParentCustomerId;
9194
}
9295

93-
static function SearchAccountsByUserId($userId)
96+
static function SearchAccountsByUserId($userId, $pageIndex, $pageSize)
9497
{
9598
$GLOBALS['Proxy'] = $GLOBALS['CustomerManagementProxy'];
9699

97100
// Specify the page index and number of account results per page.
98101

99102
$pageInfo = new Paging();
100-
$pageInfo->Index = 0; // The first page
101-
$pageInfo->Size = 100; // The first 100 accounts for this page of results
103+
$pageInfo->Index = $pageIndex;
104+
$pageInfo->Size = $pageSize;
102105

103106
$predicate = new Predicate();
104107
$predicate->Field = "UserId";

0 commit comments

Comments
 (0)