javascript - Google Calendar API - Request URL 404 Not Found -
i trying events calendar using google api:
<!doctype html> <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> <script src="googlecalendar.js"></script> <script src="https://apis.google.com/js/client.js?onload=handleclientload"></script> </head> <body> <div id="calendarcontainer"> <div> <button type="button" id="authorize-button"><?= _("google calendar events"); ?></button> </div> <div id="content"> <h2><?= _("events"); ?></h2><br> <ul id="events"></ul> </div> </div> </body> </html>
googlecalendar.js:
$(document).ready(function() { var clientid = '{my_client_id}'; var apikey = '{my_api_key}'; var scopes = 'https://www.googleapis.com/auth/calendar'; $("#authorize-button").click(function(){ handleclientload(); }); function handleclientload() { gapi.client.setapikey(apikey); window.settimeout(checkauth,1); checkauth(); } function checkauth() { gapi.auth.authorize({client_id: clientid, scope: scopes, immediate: true}, handleauthresult); } function handleauthresult(authresult) { var authorizebutton = document.getelementbyid('authorize-button'); if (authresult) { //authorizebutton.style.visibility = 'hidden'; makeapicall(); } else { authorizebutton.style.visibility = ''; authorizebutton.onclick = handleauthclick; } } function handleauthclick(event) { gapi.auth.authorize( {client_id: clientid, scope: scopes, immediate: false}, handleauthresult ); return false; } function makeapicall() { gapi.client.load('calendar', 'v3', function() { var request = gapi.client.calendar.events.list({ 'calendarid': 'primary' }); request.execute(function(resp) { console.log(resp); (var = 0; < resp.items.length; i++) { var li = document.createelement('li'); li.appendchild(document.createtextnode(resp.items[i].summary)); document.getelementbyid('events').appendchild(li); } }); }); } });
when click button in order events nothing. inspect page , this:
request url: https://content.googleapis.com/calendar/v3/calendars/primary/events?key={my_api_key}
status code: 404 not found
pasting url in browser this:
{ "error": { "errors": [ { "domain": "global", "reason": "notfound", "message": "not found" } ], "code": 404, "message": "not found" } }
why 404 not found , don't list of events calendar?
Comments
Post a Comment