如何从c#中查询Mixpanel
本文关键字:查询 Mixpanel | 更新日期: 2023-09-27 18:13:43
我对c#的web访问非常陌生,对Mixpanel完全陌生。我正试图运行一个查询与此代码:
using (WebClient wc = new WebClient())
{
wc.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
byte[] creds = UTF8Encoding.UTF8.GetBytes("<my API secret>:");
wc.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(creds));
var reqparm = new System.Collections.Specialized.NameValueCollection();
reqparm.Add("script", "function main() { return Events({'"from_date'":'"2016-10-01'",'"to_date'":'"2016-10-167'"}).reduce(mixpanel.reducer.count()); }");
byte[] responsebytes = wc.UploadValues("https://mixpanel.com/api/2.0/jql", "POST", reqparm);
}
查询直接取自Mixpanel
示例:
function main()
{
return Events
({
from_date: "2016-01-04",
to_date: "2016-01-04"
}).reduce(mixpanel.reducer.count());
}
我在上面尝试了很多变化,但UploadValues
总是返回400(错误的请求)。我做错了什么?
TIA
我没有注意到日期中有一个错误("2016-10-167")