gpt4 book ai didi

php - 从 PHP 发送 POST 批处理请求

转载 作者:行者123 更新时间:2023-12-03 17:18:03 25 4
gpt4 key购买 nike

Measurement protocol docs给我这些指示以发送批处理请求:

POST /batch HTTP/1.1
Host: www.google-analytics.com

v=1&tid=UA-XXXXX-Y&cid=555&t=pageview&dp=%2Fhome
v=1&tid=UA-XXXXX-Y&cid=555&t=pageview&dp=%2Fabout
v=1&tid=UA-XXXXX-Y&cid=555&t=pageview&dp=%2Fcontact

我对如何为此建立我的网址有点困惑?

我试过的:
$guzzle = new \GuzzleHttp\Client();
$guzzle->request('POST','www.google-analytics.com/batch',[
'query' => "v=1&tid=UA-XXXXX-Y&cid=555&t=event
v=1&tid=UA-XXXXX-Y&cid=555&t=event
v=1&tid=UA-XXXXX-Y&cid=555&t=event
v=1&tid=UA-XXXXX-Y&cid=555&t=event
v=1&tid=UA-XXXXX-Y&cid=555&t=event"
]);

这不起作用,ga 中应该有 5 个新事件,但我只收到 1 个(第一个)。

如何向测量协议(protocol)发送批处理请求?

最佳答案

如果您使用 GuzzleHttp , 你应该使用 body而不是 query :

$guzzle = new \GuzzleHttp\Client();
$guzzle->request('POST','www.google-analytics.com/batch', [
'body' => implode("\n", array(
'v=1&tid=UA-XXXXX-Y&cid=555&t=event',
'v=1&tid=UA-XXXXX-Y&cid=555&t=event',
'v=1&tid=UA-XXXXX-Y&cid=555&t=event',
'v=1&tid=UA-XXXXX-Y&cid=555&t=event',
'v=1&tid=UA-XXXXX-Y&cid=555&t=event',
)]);

关于php - 从 PHP 发送 POST 批处理请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34003879/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com