PHP code example of 5baddi / laravel-google-ads-lib

1. Go to this page and download the library: Download 5baddi/laravel-google-ads-lib 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/ */

    

5baddi / laravel-google-ads-lib example snippets


'providers' => array(
        ...
        BADDIGroup\GoogleAds\Providers\GoogleAdsServiceProvider::class
    )

'aliases' => array(
        ...
        'GoogleAds' => BADDIGroup\GoogleAds\Facades\GoogleAds::class,
    )

php artisan vendor:publish --provider="BADDIGroup\GoogleAds\Providers\GoogleAdsServiceProvider" --tag="config"

php artisan googleads:generate:refresh-token

$campaignService = $ads->service(CampaignService::class);

$results = $campaignService->select('CampaignId','CampaignName')->get();

//You can also add any where condition on the list.
$campaign = $results->where('id',1341312);


$campaign = $results->where('id',$this->testedCampaignId)->set('name','hello !!');


$string = $ads->report()
            ->format('CSVFOREXCEL')
            ->select('CampaignId','AdGroupId','AdGroupName','Id', 'Criteria', 'CriteriaType','Impressions', 'Clicks', 'Cost', 'UrlCustomParameters')
            ->from('CRITERIA_PERFORMANCE_REPORT')
            ->getAsString();

$fields = $ads->report()->from('CRITERIA_PERFORMANCE_REPORT')->getFields();