1. Go to this page and download the library: Download microsoft/msads library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
microsoft / msads example snippets
fig = \Microsoft\MsAds\Rest\Configuration::getDefaultConfiguration();
$authentication = (new \Microsoft\MsAds\Rest\Auth\OAuthDesktopMobileAuthCodeGrant())
->withEnvironment(\Microsoft\MsAds\Rest\Auth\ApiEnvironment::SANDBOX)
->withClientId(self::CLIENT_ID) // Replace with your client ID
->withOAuthScope(\Microsoft\MsAds\Rest\Auth\OAuthScope::MSADS_MANAGE);
$config->setAuthorizationData((new \Microsoft\MsAds\Rest\Auth\AuthorizationData())
->withAuthentication($authentication)
->withDeveloperToken('BBD37VB98')); // For sandbox use 'BBD37VB98'
// To set the auth key manually
// $config = $config->setApiKey('Authorization', 'YOUR_API_KEY');
// $config = $config->setApiKey('UserName', 'YOUR_API_KEY');
// $config = $config->setApiKey('CustomerAccountId', 'YOUR_API_KEY');
// $config = $config->setApiKey('CustomerId', 'YOUR_API_KEY');
// $config = $config->setApiKey('DeveloperToken', 'YOUR_API_KEY');
// $config = $config->setApiKey('Password', 'YOUR_API_KEY');
$apiInstance = new \Microsoft\MsAds\Rest\Api\CampaignManagementServiceApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new \GuzzleHttp\Client(),
$config,
null,
\Microsoft\MsAds\Rest\Auth\ApiEnvironment::SANDBOX
);
$request = new \Microsoft\MsAds\Rest\Model\CampaignManagementService\AddAdExtensionsRequest();
$request->setAdExtensions([
new \Microsoft\MsAds\Rest\Model\CampaignManagementService\ImageAdExtension([
'Name' => 'Test Image Ad Extension',
])
]);
try {
$result = $apiInstance->addAdExtensions($request);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling CampaignManagementServiceApi->addAdExtensions: ', $e->getMessage(), PHP_EOL;
}
try {
$response = $apiInstance->addAdExtensions($AddAdExtensionsRequest);
if ($response instanceof ApplicationFault) {
echo 'Handle the ApplicationFault response here';
} else {
echo 'Handle the AddAdExtensionsResponse response here';
}
} catch (ApiException $e) {
echo 'Exception when calling AdExtensionService->addAdExtensions: ', $e->getMessage(), PHP_EOL;
}
use \Microsoft\MsAds\Rest\Model\CampaignManagementService\AdExtensionsTypeFilter;
// To represent multiple AdExtensionTypeFilters:
$filter = [AdExtensionsTypeFilter::ACTION_AD_EXTENSION, AdExtensionsTypeFilter::APP_AD_EXTENSION];
// or
$filter = 'ActionAdExtension,AppAdExtension';
// or
$filter = AdExtensionsTypeFilter::ACTION_AD_EXTENSION . ',' . AdExtensionsTypeFilter::APP_AD_EXTENSION;
// or
$filter = new AdExtensionsTypeFilter($filter);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.