我无法连接到 mixpanel。
我尝试使用正确的 api_key 和 api_secret,如下所示:
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js" />
</script>
<script type="text/javascript" src="faulty-labs-md5.js" />
</script>
</head>
<body>
<script type="text/javascript">
$(document).ready(function() {
$("#btnTest").click(function() {
var api_key = 'BigSecret';
var api_secret = 'BigSecret2';
var expire = new Date('2012', '12', '24').getTime() / 1000 + 3600;
var from_date = $("#date1").val();
var to_date = $("#date2").val();
var sig = faultylabs.MD5("api_key=" + api_key + "expire=" + expire + "from_date=" + from_date + "to_date=" + to_date + api_secret);
//var path = 'https://data.mixpanel.com/api/2.0/export?api_key=' + api_key + "&expire=" + expire + "&from_date=" + from_date + "&to_date=" + to_date;
var path = 'https://data.mixpanel.com/api/2.0/export?api_key=' + api_key + "&expire=" + expire + "&from_date=" + from_date;
path = path + "&sig=" + sig.toLowerCase();
$.jsonp({
type: 'GET',
url: path,
async: false,
callback: to_date, // sneaky bogus shenanigans
callbackParameter: 'to_date', // more of same
contentType: "application/json",
dataType: 'jsonp',
cache: true,
success: function(json) {
alert(json);
},
error: function(e) {
console.log(e.message);
}
});
});
});
</script>
<input type="text" id="date1" value="2012-10-29" />
<input type="text" id="date2" value="2012-10-29" />
<button onclick="return false" id="btnTest">Test</button>
</body>
</html>
如您所见,我尝试将此 API 与 JSONP 一起使用,但我迷路了。有没有人了解mixpanel和JSONP?
先感谢您。
编辑:我添加了新版本的页面。