PHP code example of werkspot / bing-ads-api-bundle

1. Go to this page and download the library: Download werkspot/bing-ads-api-bundle 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/ */

    

werkspot / bing-ads-api-bundle example snippets


// app/AppKernel.php
public function registerBundles()
{
    $bundles = [
        //...
        new Werkspot\BingAdsApiBundle\WerkspotBingAdsApiBundle(),
        //...


use BingAds\Reporting\ReportTimePeriod;

$reportType = 'GeoLocationPerformanceReportRequest';
$timePeriod = ReportTimePeriod::LastMonth;
$columns = [
    'TimePeriod',
    'AccountName',
    'AdGroupId',
    'AdGroupName',
    'Impressions',
    'Clicks',
    'CurrencyCode',
    'Spend',
    'Country',
    'City',
    'State',
    'MetroArea',
    'MostSpecificLocation',
];

$apiDetails = new ApiDetails(
    'refreshToken',
    'clientId',
    'secret',
    'redirectUri',
    'devToken'
);
        
$bingApi = $this->get('werkspot.bing_ads_api_client');
$bingApi->setApiDetails($apiDetails);
$arrayOfFiles = $bingApi->get($columns, $reportType, $timePeriod );

/* [...] Do something with the list */

$bingApi->clearCache(); //-- When done remove the files

$newRefreshToken = $bingApi->getRefreshToken() //-- Get new RefreshToken