Javascript 向google日历api发出ajax请求
我试图向谷歌日历API发出ajax请求,但出现了一些问题。 这里我有非常简单的代码,但我不明白为什么它不工作Javascript 向google日历api发出ajax请求,javascript,jquery,ajax,google-api,Javascript,Jquery,Ajax,Google Api,我试图向谷歌日历API发出ajax请求,但出现了一些问题。 这里我有非常简单的代码,但我不明白为什么它不工作 var mykey = 'my server key'; // I am using here server key(which I created in credentials in console.developers.google.com) Maybe I am using wrong version?! I've tried browser key, but it didn't
var mykey = 'my server key'; // I am using here server key(which I created in credentials in console.developers.google.com) Maybe I am using wrong version?! I've tried browser key, but it didn't help me.
var calendarid = 'my client_id'; // here I am using VALID clientId, which I created in my project in developer console. Below this code I attached screen.
$.ajax({
type: 'GET',
url: encodeURI('https://www.googleapis.com/calendar/v3/calendars/' + calendarid+ '/events?key=' + mykey),
dataType: 'json',
success: function (response) {
//console.log('Nice!')
},
error: function (response) {
//console.log('Bad!')
}
});
我总是在浏览器控制台中出现错误404(OK)。任何帮助都将不胜感激
对于my ClientID。在联系日历API之前,您需要使用OAuth显示登录提示并获取访问令牌。最简单的方法是使用 AJAX跨域/源不正常。应该从服务器进行调用。或者这可能有效但从未测试过: