Fatal error: Uncaught Error: Access to undeclared static property:

42 views
Skip to first unread message

Pradeep Kumar

unread,
Sep 12, 2017, 1:58:51 AM9/12/17
to AdWords API Forum
Hi All,

I am stuck somewhere else right now.

AS you see in the code section 

$reportDefinition->setDateRangeType(
        ReportDefinitionDateRangeType:: LAST_7_DAYS);

I created a variable name $date which is having value LAST_7_DAYS

When i call it as mentioned below it will display an error

Code : 

$reportDefinition->setDateRangeType(
        ReportDefinitionDateRangeType:: $_GET['date']);


Error : 
 

Fatal error: Uncaught Error: Access to undeclared static property: Google\AdsApi\AdWords\Reporting\v201609\ReportDefinitionDateRangeType::$_GET in E:\server\htdocs\adwards\examples\AdWords\v201609\Reporting\CampaignsPerformancereport.php:81 Stack trace: #0 E:\server\htdocs\adwards\examples\AdWords\v201609\Reporting\CampaignsPerformancereport.php(230): Google\AdsApi\Examples\AdWords\v201609\Reporting\ParallelReportDownload::runExample(Object(Google\AdsApi\AdWords\AdWordsServices), Object(Google\AdsApi\AdWords\AdWordsSessionBuilder), 'C:\\Users\\Tech\\A...') #1 E:\server\htdocs\adwards\examples\AdWords\v201609\Reporting\CampaignsPerformancereport.php(234): Google\AdsApi\Examples\AdWords\v201609\Reporting\ParallelReportDownload::main() #2 {main} thrown in E:\server\htdocs\adwards\examples\AdWords\v201609\Reporting\CampaignsPerformancereport.php on line 81


Kindly help me to FIX.


Also with that i also want to filter report via 

Geo (location)

Device


Help me out with this also.

Vincent Racaza (AdWords API Team)

unread,
Sep 12, 2017, 4:25:23 AM9/12/17
to AdWords API Forum
Hi Pradeep,

In regards to your error in PHP, you need to set a defined constant value in the dateRangeType as the LAST_7_DAYS constant value is under ReportDefinitionDateRangeType object. Meaning, you could not just create a variable and set it in ReportDefinitionDateRangeType. Kindly set it back to original value based on the example:

$reportDefinition->setDateRangeType(
       
ReportDefinitionDateRangeType::LAST_7_DAYS);

For filtering your report by location and device, you can only filter by Device and not location in the Campaign Performance Report as there is no location ID in this report type. You can use other report types (e.g. Geo Performance ReportCampaign Location Target Report) to retrieve and filter by location.

Thanks,
Vincent
AdWords API Team

Pradeep Kumar

unread,
Sep 12, 2017, 4:44:07 AM9/12/17
to AdWords API Forum
Dear Vincent Racaza ,

Thank you for your kind reply.

But see i am developing a wordpress plugin where user has to filter the data from drop down
Like user will pick a date range e.g; 4-sep-2017 to 5-sept-2017 so i will save it in a variable and want to call this variable in place of dateRangeType.
Kindly suggest me how do i fix it in dynamic method.

Vincent Racaza (AdWords API Team)

unread,
Sep 12, 2017, 5:25:21 AM9/12/17
to AdWords API Forum
Hi Pradeep,

Since you will be using a custom date range based on the user's selection, then you can use a CUSTOM_DATE for the dateRangeType. Below is a sample PHP code snippet on how to do this:

$range = new DateRange();
$range
->setMin('20170904'); //Update this part based on the value of the user's dropdown
$range
->setMax('20170905'); //Update this part based on the value of the user's dropdown
$selector
->setDateRange($range);
$reportDefinition
->setDateRangeType(
       
ReportDefinitionDateRangeType::CUSTOM_DATE);

Also, please make sure that you import the DateRange in your file:

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

Let me know if this helps.
Reply all
Reply to author
Forward
0 new messages