Skip to content

Commit ad692d7

Browse files
authored
Merge pull request #74 from BingAds/v11-12-5
august proxy refresh
2 parents 7a0ed00 + edd8c92 commit ad692d7

File tree

101 files changed

+375
-711
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+375
-711
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# BingAds-PHP-SDK
22

3-
You can develop Bing Ads applications with any programming language that supports web services. The Bing Ads PHP Software Development Kit (SDK) enhances the experience of developing Bing Ads applications with the PHP programming language. The SDK includes a proxy to all Bing Ads API web services and abstracts low level details of authentication with OAuth. The SDK follows the PSR-4 standard to support autoloading classes from file paths, so that you don’t have to include each classes manually. Your application can simply require autoload.php: `require_once "/vendor/autoload.php";`
3+
You can develop Bing Ads applications with any programming language that supports web services. The Bing Ads PHP Software Development Kit (SDK) enhances the experience of developing Bing Ads applications with the PHP programming language. The SDK includes a proxy to all Bing Ads API web services and abstracts low level details of authentication with OAuth. The SDK follows the PSR-4 standard to support autoloading classes from file paths, so that you don’t have to include each classes manually. Your application can simply require autoload.php: `require_once __DIR__ . "/vendor/autoload.php";`
44

55
## Installing the SDK
66
You can install the Bing Ads PHP SDK using the [Composer](https://getcomposer.org/doc/00-intro.md#introduction) package manager to fetch from [Packagist](https://packagist.org/packages/microsoft/bingads). We recommend using Composer as a dependency manager so that you don’t have to manually download the proxy classes.
77

8-
1. Download and install [Composer](https://getcomposer.org/doc/00-intro.md#introduction). Microsoft Windows users should also add composer.phar to your *PATH* variable.
8+
1. Download and install [Composer](https://getcomposer.org/doc/00-intro.md#introduction). Microsoft Windows users should also add composer.phar to your *PATH* variable.
99

10-
2. Open a command prompt and type `composer require microsoft/bingads`.
10+
2. Open a command prompt and type `composer require microsoft/bingads`.
1111

12-
**Note:** Windows users who did not add *composer.phar* to the *PATH* will need to type `php composer.phar require microsoft/bingads` instead.
12+
**Note:** Windows users who did not add *composer.phar* to the *PATH* will need to type `php composer.phar require microsoft/bingads` instead.
1313

14-
3. To get updates going forward, type `composer update`. If any updates are available at packagist, composer will install the latest version.
14+
3. To get updates going forward, type `composer update`. If any updates are available at packagist, composer will install the latest version.
1515

1616
For more information see [Get Started Using PHP with Bing Ads Services](https://docs.microsoft.com/en-us/bingads/guides/get-started-php).

samples/V11/AdExtensions.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
// For more information about installing and using the Bing Ads PHP SDK,
66
// see https://go.microsoft.com/fwlink/?linkid=838593.
77

8-
require_once "/../vendor/autoload.php";
8+
require_once __DIR__ . "/../vendor/autoload.php";
99

10-
include "/AuthHelper.php";
11-
include "/OutputHelper.php";
12-
include "/CampaignManagementExampleHelper.php";
10+
include __DIR__ . "/AuthHelper.php";
11+
include __DIR__ . "/OutputHelper.php";
12+
include __DIR__ . "/CampaignManagementExampleHelper.php";
1313

1414
use SoapVar;
1515
use SoapFault;

samples/V11/AdInsightExampleHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Microsoft\BingAds\Samples\V11;
44

5-
require_once "/../vendor/autoload.php";
5+
require_once __DIR__ . "/../vendor/autoload.php";
66

77
use SoapVar;
88
use SoapFault;

samples/V11/AdInsightHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// For more information about installing and using the Bing Ads PHP SDK,
66
// see https://go.microsoft.com/fwlink/?linkid=838593.
77

8-
require_once "/../vendor/autoload.php";
8+
require_once __DIR__ . "/../vendor/autoload.php";
99

1010

1111
use SoapVar;

samples/V11/AuthHelper.php

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
namespace Microsoft\BingAds\Samples\V11;
44

5-
require_once "/../vendor/autoload.php";
5+
require_once __DIR__ . "/../vendor/autoload.php";
66

7-
require_once "/CustomerManagementExampleHelper.php";
7+
require_once __DIR__ . "/CustomerManagementExampleHelper.php";
88

99
// Specify the Microsoft\BingAds\Auth classes that will be used.
1010

11-
use Microsoft\BingAds\Auth\PasswordAuthentication;
1211
use Microsoft\BingAds\Auth\OAuthDesktopMobileAuthCodeGrant;
1312
use Microsoft\BingAds\Auth\OAuthWebAuthCodeGrant;
1413
use Microsoft\BingAds\Auth\AuthorizationData;
@@ -41,8 +40,8 @@
4140
*/
4241
final class AuthHelper {
4342

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;
4645
const OAuthRefreshTokenPath = 'refresh.txt';
4746
const ClientId = 'ClientIdGoesHere';
4847
const ClientSecret = 'ClientSecretGoesHere';
@@ -76,10 +75,6 @@ static function Authenticate()
7675
// instead of providing the Bing Ads username and password set.
7776
AuthHelper::AuthenticateWithOAuth();
7877

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-
8378
$GLOBALS['CustomerManagementProxy'] = new ServiceClient(
8479
ServiceClientType::CustomerManagementVersion11,
8580
$GLOBALS['AuthorizationData'],
@@ -118,21 +113,6 @@ static function SearchAccountsByUserId($userId)
118113
return $GLOBALS['Proxy']->GetService()->SearchAccounts($request);
119114
}
120115

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-
136116
// Sets the global authorization data instance with OAuthDesktopMobileAuthCodeGrant.
137117

138118
static function AuthenticateWithOAuth()

samples/V11/BudgetOpportunities.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
// For more information about installing and using the Bing Ads PHP SDK,
66
// see https://go.microsoft.com/fwlink/?linkid=838593.
77

8-
require_once "/../vendor/autoload.php";
8+
require_once __DIR__ . "/../vendor/autoload.php";
99

10-
include "/AuthHelper.php";
11-
include "/AdInsightExampleHelper.php";
12-
include "/CampaignManagementExampleHelper.php";
10+
include __DIR__ . "/AuthHelper.php";
11+
include __DIR__ . "/AdInsightExampleHelper.php";
12+
include __DIR__ . "/CampaignManagementExampleHelper.php";
1313

1414
use SoapVar;
1515
use SoapFault;

samples/V11/BulkDownloadUpload.php

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
// For more information about installing and using the Bing Ads PHP SDK,
66
// see https://go.microsoft.com/fwlink/?linkid=838593.
77

8-
require_once "/../vendor/autoload.php";
8+
require_once __DIR__ . "/../vendor/autoload.php";
99

10-
include "/AuthHelper.php";
11-
include "/BulkExampleHelper.php";
10+
include __DIR__ . "/AuthHelper.php";
11+
include __DIR__ . "/BulkExampleHelper.php";
1212

1313
use SoapVar;
1414
use SoapFault;
@@ -270,23 +270,15 @@ function UploadFile($uploadUrl, $filePath)
270270
throw new Exception("AuthorizationData is not set.");
271271
}
272272

273-
// If you are using OAuth, then you must include the AuthenticationToken header element
274-
// instead of UserName and Password.
273+
// Set the authorization headers.
275274
if(isset($GLOBALS['AuthorizationData']->Authentication) && isset($GLOBALS['AuthorizationData']->Authentication->Type))
276275
{
277276
$authorizationHeaders = array();
278277
$authorizationHeaders[] = "DeveloperToken: " . $GLOBALS['AuthorizationData']->DeveloperToken;
279278
$authorizationHeaders[] = "CustomerId: " . $GLOBALS['AuthorizationData']->CustomerId;
280279
$authorizationHeaders[] = "CustomerAccountId: " . $GLOBALS['AuthorizationData']->AccountId;
281280

282-
if($GLOBALS['AuthorizationData']->Authentication->Type == "PasswordAuthentication")
283-
{
284-
$authorizationHeaders[] = "UserName: " . $GLOBALS['AuthorizationData']->Authentication->UserName;
285-
$authorizationHeaders[] = "Password: " . $GLOBALS['AuthorizationData']->Authentication->Password;
286-
}
287-
elseif($GLOBALS['AuthorizationData']->Authentication->Type == "OAuthWebAuthCodeGrant" ||
288-
$GLOBALS['AuthorizationData']->Authentication->Type == "OAuthDesktopMobileAuthCodeGrant" ||
289-
$GLOBALS['AuthorizationData']->Authentication->Type == "OAuthDesktopMobileImplicitGrant")
281+
if(isset($GLOBALS['AuthorizationData']->Authentication->OAuthTokens))
290282
{
291283
$authorizationHeaders[] = "AuthenticationToken: " . $GLOBALS['AuthorizationData']->Authentication->OAuthTokens->AccessToken;
292284
}

samples/V11/BulkExampleHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Microsoft\BingAds\Samples\V11;
44

5-
require_once "/../vendor/autoload.php";
5+
require_once __DIR__ . "/../vendor/autoload.php";
66

77
use SoapVar;
88
use SoapFault;

samples/V11/CampaignManagementExampleHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Microsoft\BingAds\Samples\V11;
44

5-
require_once "/../vendor/autoload.php";
5+
require_once __DIR__ . "/../vendor/autoload.php";
66

77
use SoapVar;
88
use SoapFault;

samples/V11/ConversionGoals.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
// For more information about installing and using the Bing Ads PHP SDK,
66
// see https://go.microsoft.com/fwlink/?linkid=838593.
77

8-
require_once "/../vendor/autoload.php";
8+
require_once __DIR__ . "/../vendor/autoload.php";
99

10-
include "/AuthHelper.php";
11-
include "/CampaignManagementExampleHelper.php";
10+
include __DIR__ . "/AuthHelper.php";
11+
include __DIR__ . "/CampaignManagementExampleHelper.php";
1212

1313
use SoapVar;
1414
use SoapFault;
@@ -392,4 +392,4 @@
392392
print $e->getCode()." ".$e->getMessage()."\n\n";
393393
print $e->getTraceAsString()."\n\n";
394394
}
395-
}
395+
}

0 commit comments

Comments
 (0)