I am trying to use the Google Docs API to get spreadsheet data as XML, and eventually JSON data. I have put the URL (http://spreadsheets.google.com/feeds/list/0Aizy-VIdLC0QdDNNRkpfVncxQzZRNG9fMVhueXVMenc/1/private/values) in my browser, and I get the data, even when not logged in to Google.
When I try with jQuery Ajax, I get the "page not found" error.
$.get('http://spreadsheets.google.com/feeds/list/0Aizy-VIdLC0QdDNNRkpfVncxQzZRNG9fMVhueXVMenc/1/private/values', function(data) {
console.log(data)
});
I am guessing that same origin policy might be the cause of the Ajax error, so I tried with PHP, but I get the error.
echo file_get_contents("http://spreadsheets.google.com/feeds/list/0Aizy-VIdLC0QdDNNRkpfVncxQzZRNG9fMVhueXVMenc/1/private/values");
I am aiming to get the Google Docs spreadsheet data into a JSON object for use on a webpage.
How can I fix this error?
You have to be logged in in order to be able to retrieve the spreadsheet data.
Visiting http://spreadsheet.google.com/.../private/values while logged in results in a meaningful XML page. Trying to load the same page when not logged in, however, results in a "Page Not Found".
According to the response header from the JQuery response, the only cause of this error is not being logged in (shown below).
WWW-Authenticate: No credentials were included in your request.
See The Protocol Guide for the relevant documentation.