Google AnalyticsAPI请求上传数据javascript

时间:2016-07-01 17:35:13

标签: javascript api google-analytics google-analytics-api

我正在尝试向Google Analytics发送upload请求。我正在尝试使用

$.ajax({
  url: 'https://www.googleapis.com/upload/analytics/v3/management/accounts/76065140/webproperties/UA-76065140-1/customDataSources/5Qtzai0hSAatCidaDzhyHg/uploads',
  method:"POST",
  success: function(){
    alert('123');
  }
});

返回Status Code:401 Login Required。我需要登录吗?我已经创建了一个服务私钥(在json中),但我该如何使用密钥?

我在哪里将其添加到请求中?

我试试

$.ajax({
  url: 'https://www.googleapis.com/upload/analytics/v3/management/accounts/76065140/webproperties/UA-76065140-1/customDataSources/5Qtzai0hSAatCidaDzhyHg/uploads',
  data:"key=MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCS/0bCGAff/iCs\nBW8hGSu9F7iU95qjzwaf6xaNbxUcbYxUeIdLeFQpsYvMDuc2RToV56Yt9vc+40s2\nfGHVO2DfF4JJv3hJHdb/Emc0dPfJ/86riONbY2vTGsx9kxToruRqywzDaH/LsIL8\nxLPDDV3RmQ0XKuCS0hGlPakPeyOi+nLikAiVyNE6vHVKmTrcDEL6BKkM+l2BLa/m\n0jZH8GmxBmCLxzK4zWs0kFh9SSXjfC6f7Ydr1XR8U4bSadD6t2GSCZ54heXF2Y61\neLAPWViIGcWJevLzJdV6p4Tz3dooBREKO8QIpWV6CD/H3Z9lhuSrq/tsQcjv9u/P\nB/xfbREnAgMBAAECggEAOd3CNhANsZCxveYZvDbTcAnRgNsEBi4uVm/OHfk3n0xE\nrNARupTw1MTu2nKXdFbGKe9aDMgmxpvldNp8DNvmI4x2np+AM5BKnXjaJd1R2jQY\nYJBvp/84aA8pptlqprqKcrviF16gyEeBGQ46EbPGVgdhDtizNTj690iRr+Vyvuot\nl0J9DaE7A/f97TRRdOWzZnsnP6Hy37s0OLgRioq3f1hMm8KcCibnGTQpti+b8lAZ\n0A75f/GE3V0DnPscvrgiFVjnYzdtcH1XXXX41hop+fe0c9gbIvGyfllZGzDo54Cu\n5w31DLDIIqvOyG0o7DW4cUWchnFhcUrllHFE+ZP0kQKBgQDPEERaXn7sWqnTkueS\nLqbvpfGG4RePCzR+Ktan+xFmWlvFpNk5DacfUbpKN9iemFB013MxNvFBofpT3lBX\nhO5Q4r6LQvTDU+nTJJMXtHC7FoMQ7k4HDdm1VWQ1v56wR0IlZ3/alkkg/3GFXo/0\nNIOZ1BkYqG8mI+4A3r+Pk0QySQKBgQC1vOGcpr1M7Kox0MG3qyvoqm2NpepXxEYi\n+tI+kGI+F1nDk0cVp0U0I70wnF7f2JdMWihWrH3Ti4MxXavtwfv7Ogt425401Tyb\nR2opYxCz3jo11grTokAOFeJRnCioVz6YU26P6AHw/kkd73OASo7PsIHFV9VL4D6R\nVTW55lEn7wKBgQCaPkDcnHWptOO64jy0LSJXdGLVmYlGGg+xSFH8cc8FUpv4P5M8\np8ntT6EYtj8b7NRKJU/+wjG3NWTW4s0wVKp+AFn2PRs9AZ41lZIo31X2V4+spgfj\nw1KAfKqYSzR3la1VVaLs/nRdK0uyEL3lKNU7Wr6TGq0pWSxq44MI/aeYWQKBgQCu\nDnOJ48vjk7rBMS2HKgJIuIlqI2CYpFuD/vNDhmcBDr4i6LgpDeXitOPqXakj/D2T\nm7mMoXF1HOYObqdOc/5Qs1vvaW9RLHT6RuBvOPjzO8BGdXQzEu8EToNOJCBwcfZ6\nT1XRr6PEWtZOPFpDoaS7V1JCXgfjvqZN7O0i2WoaswKBgGDm/AWxfxyPMpjvS0q+\nxNbUQj063q+8Sc9/Vu/5j8Rp7CfZBjAOlxpO8z2WsyNdS12ubL7yK3dY4wVNWV9J\ntMN9zpiKWCq787dLnN/m+KA5WSroY2umDw1HUEymEjxh4N0Ib1k5ArfT9Dl0kSJG\nKGS1wkh34a4kx4r90IUfPL4L",
  method:"POST",
  success: function(){
    alert('Load was performed.');
  }
});

但它没有工作

0 个答案:

没有答案