How can I use mixpanel API?

前端 未结 6 1936
抹茶落季
抹茶落季 2021-02-04 14:34

I\'m not able to connect to mixpanel.

I have tried with a correct api_key and api_secret, like this:



    

        
6条回答
  •  有刺的猬
    2021-02-04 15:36

    After squinting at this PHP, I'm pretty sure you need to do an md5 hash of your api signature.

    Import an md5 library, like this one

    
    

    And then do something like this:

    var sig = "api_key=" + api_key + "expire=" + expire + "from_date=" + from_date + "to_date=" + to_date + "bigsecret2";
    sig = $.md5(sig);
    

    I'm trying to accomplish the same thing you are, but unfortunately I still haven't got it working.

    Edit - This is rough. The API will fail if ANY parameter is not hashed with the sig. It will also fail if any parameter is included which is not part of the API. JsonP adds a "callback" and a "_" timestamp parameter so it can do what it does, and this breaks the call. You can hack around this by excluding the timestamp with cache: true and using a special jsonp plugin which allows you to rename the callback parameter. Here I have renamed it to to_date and named the callback function "2012-10-29". It's crazy, and it still doesn't work because the reply is not valid json. It's a series of newline-delimited json objects which can not be evaluated, and I'm still stuck on that part. Here's what I've got so far:

    
    
    
    
    
    

    Ultimately I threw up my hands and wrote a C# program to hit the API and spit out a CSV for me.

提交回复
热议问题