Closed mansouralex closed 7 years ago
Hey @mansouralex
Something like this:
<?php
namespace App\Http\Controllers;
use Google\AdsApi\AdWords\Reporting\v201609\ReportDownloader;
use Google\AdsApi\AdWords\AdWordsSession;
use LaravelGoogleAds\Services\AdWordsService;
class ReportController extends Controller
{
/**
* @var AdWordsService $adWordsService
*/
private $adWordsService;
public function __construct()
{
$this->adWordsService = new AdWordsService();
}
/**
* @return void
*/
public function report()
{
/** @var AdWordsSession $session */
$session = $this->adWordsService->session('CLIENT_CUSTOMER_ID');
// Create report query to get the data for last 7 days.
$reportQuery = 'SELECT CampaignId, AdGroupId, Id, Criteria, CriteriaType, '
. 'Impressions, Clicks, Cost FROM CRITERIA_PERFORMANCE_REPORT '
. 'WHERE Status IN [ENABLED, PAUSED] DURING LAST_7_DAYS';
$reportDownloader = new ReportDownloader($session);
$reportDownloadResult = $reportDownloader->downloadReportWithAwql($reportQuery, $reportFormat);
print "Report was downloaded and printed below:\n";
print $reportDownloadResult->getAsString();
}
}
You need to provide a CLIENT_CUSTOMER_ID!
@yooouuri Thanks for your reply. Have already solved it.
Hi @nikolajlovenhardt, Thanks for this wrapper.
Could you provide a sample or some hints how we can implement https://github.com/googleads/googleads-php-lib/blob/master/examples/AdWords/v201702/Reporting/DownloadCriteriaReportWithAwql.php using this Laravel wrapper ?
Thanks.