Я использую API Google Analytics для создания отчета Google Analytics.
Я реализую фильтры, в фильтре, я хочу убедиться, что,
ga:contentGroup2!=Answered;ga:pageviews!=0
вот мой код,
$processing[1] = str_replace('filters=', '' , $e1_param_url[$i]); //, here $processing[1] will be ga:contentGroup2!=Answered;ga:pageviews!=0
$e1_filters = explode(';' , $processing[1]);
for($k_filters =0; $k_filters < count($e1_filters); $k_filters++){
$operator = '';
for($c_ops =0; $c_ops < count($operators); $c_ops++){
$operator = strpos($e1_filters[$k_filters],$operators[$c_ops]) != false ? $operators[$c_ops] : '';
if($operator != '') break;
}
$the_filter = explode($operator , $e1_filters[$k_filters]);
if(in_array($the_filter[0],$metrics)){
$metricFilter = new Google_Service_AnalyticsReporting_MetricFilter();
$metricFilter->setMetricName($the_filter[0]);
if(strpos('!',$operator)!= false)
$metricFilter->setNot(true);
$metricFilter->setOperator($this->getOperator($operator));
$metricFilter->setComparisonValue($the_filter[1]);
array_push($metricFilters , $metricFilter);
}else{
$dimensionFilter = new Google_Service_AnalyticsReporting_DimensionFilter();
$dimensionFilter->setDimensionName($the_filter[0]);
if(strpos('!',$operator)!= false)
$dimensionFilter->setNot(true);
$dimensionFilter->setOperator($this->getOperator($operator));
$dimensionFilter->setExpressions(array($the_filter[1]));
array_push($dimensionsFilters , $dimensionFilter);
}
}
и вот моя функция $ this-> getOperator
// get this list from: https://developers.google.com/analytics/devguides/reporting/core/v4/rest/v4/reports/batchGet#Operator
function getOperator($operator){
switch($operator){
case '==':
return 'EXACT';
case '!=':
return 'EXACT';
case '>=':
return 'NUMERIC_GREATER_THAN';
case '<=':
return 'NUMERIC_LESS_THAN';
default:
return null;
}
}
так, в случае! = Что я должен вернуть?