【发布时间】:2019-05-13 10:53:49
【问题描述】:
我正在尝试使用 php7 进行设置,并为我的 rest API 设置 guzzle。当我使用 cli 在 curl 中将请求发送到调试 url 时,我得到了一个不错的 json 响应
{
"hitParsingResult": [ {
"valid": true,
"parserMessage": [ ],
"hit": "/debug/collect?v=1\u0026t=pageview\u0026tid=UA-1234567-1\u0026uid=UA-1234567-1\u0026dh=test.domain.com\u0026dp=/api/user/verify/flow"
} ],
"parserMessage": [ {
"messageType": "INFO",
"description": "Found 1 hit in the request."
} ]
}
但如果我将它发送到产品 url,我每次都会收到奇怪的响应
GIF89a▒▒▒▒▒,D;
有人知道怎么解决吗?
这是我在cli上运行的
curl -X POST -d 'v=1&t=pageview&tid=UA-xxxxxxxxx-1&uid=UA-xxxxxxxxx-1&dh=test.domain.com&dp=%2Fiwsapi%2Fuser%2Fverify%2Fflow' https://www.google-analytics.com/debug/collect
对于非调试模式,我只是删除调试
curl -X POST -d 'v=1&t=pageview&tid=UA-xxxxxxxxx-1&uid=UA-xxxxxxxxx-1&dh=test.domain.com&dp=%2Fiwsapi%2Fuser%2Fverify%2Fflow' https://www.google-analytics.com/collect
在 guzzle 中,我正在构建它
$promise = $guzzle->post("/debug/collect", [
'proxy' => [
'http' => 'http://proxy:8080',
'https' => 'http://proxy:8080',
],
'form_params'=>[
'v'=>1,
't'=>'pageview',
'tid'=>GOOGLE_ID,
'uid'=>$_SERVER['HTTP_CTVFNTUSERNAME'],
'dh'=>WWWHOST,
'dp'=>$_SERVER['REQUEST_URI'],
//'dt'=>'homepage'
]
]);
【问题讨论】:
标签: curl google-analytics php-7 guzzle measurement-protocol