2017-06-11 2 views
0

AdWordsレポートのセレクタにカスタム期間を追加しようとしましたが、取得する日付を取得できません。私は未定義の関数呼び出し 'DateRange'を取り戻しています。

誰もこれを理解できましたか?

class ParallelReportDownload { 

// Timeout between retries in seconds. 
const BACKOFF_FACTOR = 5; 

// Maximum number of retries for 500 errors. 
const MAX_RETRIES = 5; 

// The number of entries per page of the results. 
const PAGE_LIMIT = 500; 

public static function runExample(AdWordsServices $adWordsServices, 
    AdWordsSessionBuilder $sessionBuilder, $reportDir) { 
// Construct an API session for the client customer ID specified in the 
// configuration file. 
$session = $sessionBuilder->build(); 

// Create selector. 
$selector = new Selector(); 
$selector->setFields(['Month', 'Impressions', 'Clicks', 'Ctr', 'AverageCpc', 'AveragePosition', 'Cost', 'Conversions', 'CostPerConversion', 'ConversionRate', 'SearchImpressionShare']); 

//THIS CODE WAS FOUND ON GOOGLE API FORUM 
$selector->dateRange = new DateRange(); 
$selector->dateRange->min = date('Ymd', strtotime('2017/06/01')); 
$selector->dateRange->max = date('Ymd', strtotime('2017/06/09')); 

// Use a predicate to filter out paused criteria (this is optional). 
//$selector->setPredicates([ 
    //new Predicate('Impressions', PredicateOperator::GREATER_THAN, [1000]), 
    //new Predicate('CampaignName', PredicateOperator::CONTAINS, ['Branded']) 
    //]); 

// Create report definition. 
$reportDefinition = new ReportDefinition(); 
$reportDefinition->setSelector($selector); 
$reportDefinition->setReportName('LAST_MONTH ACCOUNT_PERFORMANCE_REPORT'); 
$reportDefinition->setDateRangeType(
    ReportDefinitionDateRangeType::CUSTOM_DATE); 
$reportDefinition->setReportType(
    ReportDefinitionReportType::ACCOUNT_PERFORMANCE_REPORT); 
$reportDefinition->setDownloadFormat(DownloadFormat::CSV); 

$customerIds = self::getAllManagedCustomerIds($adWordsServices, $session); 
printf("Downloading reports for %d managed customers.\n", 
    count($customerIds)); 

$successfulReports = []; 
$failedReports = []; 

foreach ($customerIds as $customerId) { 

    $filePath = "../../../../../../clients/client_reports/accounts/" . $customerId . "_LAST_MONTH___account.csv"; 

私はエラーメッセージを取得しています:致命的なエラー:クラスの 'Google \ AdsAPIのアドワーズ\例を\ v201705 \レポーティング\のDateRange \' には見られない/ホーム/ mtrant/public_htmlの/クライアント/バックエンド/ API /アドワーズ/ production/paidsearch/reports/selector/all_MOM_ACCOUNT_PERFORMANCE_REPORT.php on line 69

ご協力いただければ幸いです。

答えて

2

まず第一に、あなたのコードの先頭でこれを含める:

use Google\AdsApi\AdWords\v201705\cm\DateRange; 

すると以下のようなあなたのセレクタに日付範囲を追加します。

$selector->setDateRange(new DateRange($FromDate, $ToDate)); 

これはあなたの問題を解決する必要があります。 私のために解決しました。 これらの変更を行った後でもエラーが発生した場合は更新してください。

+0

これは完璧に機能しました。ありがとうございました。 –

+0

セレクター(orderby月)に 'orderby'を追加できますか?私はいつもAWQLを使用しており、セレクタに調整するのが苦労しています。 –

+0

この回答に便利な@マークトレンターをマークしてください。あなたを助けてうれしい –

関連する問題