我尝试在查询上应用过滤器,并得到一个致命错误这里是源代码:
require 'vendor/autoload.php';
use Google\Analytics\Data\V1beta\BetaAnalyticsDataClient;
use Google\Analytics\Data\V1beta\OrderBy;
use Google\Analytics\Data\V1beta\OrderBy\MetricOrderBy;
use Google\Analytics\Data\V1beta\DateRange;
use Google\Analytics\Data\V1beta\Dimension;
use Google\Analytics\Data\V1beta\Metric;
use Google\Analytics\Data\V1beta\Filter;
use Google\Analytics\Data\V1beta\Filter\StringFilter;
use Google\Analytics\Data\V1beta\FilterExpression;
use Google\Analytics\Data\V1beta\Filter\StringFilter\MatchType;
$property_id = XXXX;
$response_cpc = $client->runReport([
'property' => 'properties/' . $property_id,
'dateRanges' => [
new DateRange([
'start_date' => $_GET["date"],
'end_date' => $_GET["date"],
]),
],
'dimensions' => [new Dimension(
[
'name' => 'firstUserSourceMedium',
]
)],[new Dimension(
[
'name' => 'firstUserCampaignName',
]
)
],
'metrics' => [new Metric(
[
'name' => 'sessions',
]
),new Metric(
[
'name' => 'bounceRate',
]
),
new Metric(
[
'name' => 'conversions:Newsletter_signup',
]
),
new Metric(
[
'name' => 'screenPageViewsPerSession',
]
),
new Metric(
[
'name' => 'transactions',
]
),
new Metric(
[
'name' => 'conversions:go_to_amazon',
]
)
],
'dimensionFilter' => [new FilterExpression (
[
'filter' => [new Filter(
[
'field_name' => 'firstUserSourceMedium',
'string_filter' => [new StringFilter([
'match_type' => Filter\StringFilter\MatchType::BEGINS_WITH,
'value' => 'cpc',
'case_sensitive'=> false,
]
)]
]
)]
]
)],
'limit'=> 25,
'orderBys' =>[ new OrderBy([
'metric' => new MetricOrderBy([
'metric_name' =>'sessions']
),
'desc'=>true,
])],
]);
print_r($response_cpc);
这是我得到的错误:
致命错误:未捕获异常:预期为Google\Analytics\Data\V1beta\Filter\StringFilter。在/home/Server 1/xagyrxxhed/public_html/vendor/google/protobuf/src/Google/Protobuf/Internal/GPBUtil.php:198堆栈跟踪:Copyright © 2018 - 2019 www.xagyrxxhed.com. All Rights Reserved.粤ICP备16048888号-1 Google\Protobuf\Internal\GPBUtil::checkMessage()#1 /home/Server1/xagyrxxhed/public_html/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(1082):Copyright © 2018 - 2019 www.xagyrxxhed.com. All Rights Reserved.粤ICP备16049562号-1 Copyright © 2018 - 2019 www.xagyrxxhed.com. All Rights Reserved.粤ICP备15048888号-1 Copyright © 2018 - 2019 www.jsjsj.com All Rights Reserved.粤ICP备15048888号-1会话信息:SESSION_ID = bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
有什么帮助吗?
1条答案
按热度按时间bnlyeluc1#
修复:1-内存增加2-代码更改:去掉一些[