gpt4 book ai didi

jquery - 使用 jquery ajax 调用 mixpanel

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

我需要使用 jQuery 来使用 mixpanel 数据导出 API。
据此:How can I use mixpanel API?根据 mixpanel:https://mixpanel.com/docs/api-documentation/data-export-api#libs-js ,我可以用这个:

$.getJSON('http://mixpanel.com/api/2.0/engage/?callback=?', {
api_key: apiKey,
expire: expire,
sig: sig
},
function (result) {
alert(result);
}
);

但结果我得到一个错误:

"unknown param: callback
for params: {'callback': 'jQuery18208090281161325954_1358248117308', 'project_id': 160130}"

自从我在http://mixpanel.com/api/2.0/engage/?api_key=...&expire=...&sig=中打开浏览器以来,我知道网址和我的数据是正确的。 ..我得到了正确的数据。

我的代码有什么问题吗?

最佳答案

您的代码没有任何问题。

callback 参数适用于其他端点,例如 .../events/top.../funnels/list,但是这个对于这个特定的engage端点返回错误。

您必须向 Mixpanel 提出此问题,因为该端点不支持 JSONP 回调。

有点令人困惑的是,您可以按照本页上的说明使用不同的engage端点发布数据: https://mixpanel.com/docs/people-analytics/people-http-specification-insert-data

以下是使用此端点的示例:

var mixpanel_token = "<insert token for your mixpanel project here>";
var myData = { "$set": {
"$first_name": "John",
"$last_name": "Smith" },
"$token": mixpanel_token,
"$distinct_id": "99999",
"$ip": "0" };

var dataEncodedToBase64 = window.btoa(JSON.stringify(myData));

var path = 'http://api.mixpanel.com/engage?callback=?';

$.getJSON(path, { 'data': dataEncodedToBase64, 'verbose': 1 }, function(json) {
console.log("Success");
console.log(json);
});

请注意,您的代码应该适用于您在问题中提供的链接中的其他端点,但不适用于engage

关于jquery - 使用 jquery ajax 调用 mixpanel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14336594/

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