如何使用 CURL 将我们的请求发送到 www.google-analytics.com/collect

问题描述

我一直在浏览 Universal analytics measurement protocol

的文档

我已经得到了url和参数,现在我有一个问题是如何使用CURL发出HTTP请求,这是我的请求:

curl https://www.google-analytics.com/collect -d v=1&tid=UA-123456-1&cid=5555&t=pageview&dp=%2FpageA

错误:

警告:二进制输出可能会弄乱您的终端。使用“--output-”来告诉 警告:无论如何 curl 将其输出到您的终端,或者考虑“--output 警告:“保存到文件。

你能告诉我我的请求有什么问题吗?

解决方法

我会先使用调试端点对其进行测试。

curl 'https://www.google-analytics.com/debug/collect?v=1&tid=UA-123456-1&cid=5555&t=pageview&dp=%2FpageA'

回复说一切都好。

{
  "hitParsingResult": [ {
    "valid": true,"parserMessage": [ ],"hit": "/debug/collect?v=1\u0026tid=UA-123456-1\u0026cid=5555\u0026t=pageview\u0026dp=%2FpageA"
  } ],"parserMessage": [ {
    "messageType": "INFO","description": "Found 1 hit in the request."
  } ]
}

接着发送实际命中。

curl 'https://www.google-analytics.com/collect?v=1&tid=UA-123456-1&cid=5555&t=pageview&dp=%2FpageA'

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...