|
2 | 2 |
|
3 | 3 | namespace Microsoft\BingAds\Samples\V11; |
4 | 4 |
|
5 | | -require_once "/../vendor/autoload.php"; |
| 5 | +require_once __DIR__ . "/../vendor/autoload.php"; |
6 | 6 |
|
7 | | -require_once "/CustomerManagementExampleHelper.php"; |
| 7 | +require_once __DIR__ . "/CustomerManagementExampleHelper.php"; |
8 | 8 |
|
9 | 9 | // Specify the Microsoft\BingAds\Auth classes that will be used. |
10 | 10 |
|
11 | | -use Microsoft\BingAds\Auth\PasswordAuthentication; |
12 | 11 | use Microsoft\BingAds\Auth\OAuthDesktopMobileAuthCodeGrant; |
13 | 12 | use Microsoft\BingAds\Auth\OAuthWebAuthCodeGrant; |
14 | 13 | use Microsoft\BingAds\Auth\AuthorizationData; |
|
41 | 40 | */ |
42 | 41 | final class AuthHelper { |
43 | 42 |
|
44 | | - const DeveloperToken = 'DeveloperTokenGoesHere'; // For sandbox use BBD37VB98 |
45 | | - const ApiEnvironment = ApiEnvironment::Production; |
| 43 | + const DeveloperToken = 'BBD37VB98'; // For sandbox use BBD37VB98 |
| 44 | + const ApiEnvironment = ApiEnvironment::Sandbox; |
46 | 45 | const OAuthRefreshTokenPath = 'refresh.txt'; |
47 | 46 | const ClientId = 'ClientIdGoesHere'; |
48 | 47 | const ClientSecret = 'ClientSecretGoesHere'; |
@@ -76,10 +75,6 @@ static function Authenticate() |
76 | 75 | // instead of providing the Bing Ads username and password set. |
77 | 76 | AuthHelper::AuthenticateWithOAuth(); |
78 | 77 |
|
79 | | - // Bing Ads API Version 11 is the last version to support UserName and Password authentication, |
80 | | - // so this method is deprecated. |
81 | | - //AuthHelper::AuthenticateWithUserName(); |
82 | | - |
83 | 78 | $GLOBALS['CustomerManagementProxy'] = new ServiceClient( |
84 | 79 | ServiceClientType::CustomerManagementVersion11, |
85 | 80 | $GLOBALS['AuthorizationData'], |
@@ -118,21 +113,6 @@ static function SearchAccountsByUserId($userId) |
118 | 113 | return $GLOBALS['Proxy']->GetService()->SearchAccounts($request); |
119 | 114 | } |
120 | 115 |
|
121 | | - // Sets the global authorization data instance with PasswordAuthentication. |
122 | | - // Bing Ads API Version 11 is the last version to support UserName and Password authentication, |
123 | | - // so this function is deprecated. |
124 | | - |
125 | | - static function AuthenticateWithUserName() |
126 | | - { |
127 | | - $authentication = (new PasswordAuthentication()) |
128 | | - ->withUserName(AuthHelper::UserName) |
129 | | - ->withPassword(AuthHelper::Password); |
130 | | - |
131 | | - $GLOBALS['AuthorizationData'] = (new AuthorizationData()) |
132 | | - ->withAuthentication($authentication) |
133 | | - ->withDeveloperToken(AuthHelper::DeveloperToken); |
134 | | - } |
135 | | - |
136 | 116 | // Sets the global authorization data instance with OAuthDesktopMobileAuthCodeGrant. |
137 | 117 |
|
138 | 118 | static function AuthenticateWithOAuth() |
|
0 commit comments