Bil*_*oon 0 javascript xml ajax google-docs-api
我正在尝试使用Google Docs API将电子表格数据作为XML,最终获得JSON数据.我已将URL(http://spreadsheets.google.com/feeds/list/0Aizy-VIdLC0QdDNNRkpfVncxQzZRNG9fMVhueXVMenc/1/private/values)放入浏览器,即使未登录Google,我也会获取数据.
当我尝试使用jQuery Ajax时,我收到"找不到页面"错误.
$.get('http://spreadsheets.google.com/feeds/list/0Aizy-VIdLC0QdDNNRkpfVncxQzZRNG9fMVhueXVMenc/1/private/values', function(data) {
console.log(data)
});
Run Code Online (Sandbox Code Playgroud)
我猜相同的源策略可能是Ajax错误的原因,所以我尝试使用PHP,但是我得到了错误.
echo file_get_contents("http://spreadsheets.google.com/feeds/list/0Aizy-VIdLC0QdDNNRkpfVncxQzZRNG9fMVhueXVMenc/1/private/values");
Run Code Online (Sandbox Code Playgroud)
我的目标是将Google Docs电子表格数据转换为JSON对象,以便在网页上使用.
我该如何解决这个错误?
您必须登录才能检索电子表格数据.
登录后访问http://spreadsheet.google.com/.../private/values会生成有意义的XML页面.但是,在未登录时尝试加载相同的页面会导致"找不到页面".
根据JQuery响应的响应头,导致此错误的唯一原因是没有登录(如下所示).
WWW-Authenticate: No credentials were included in your request.
Run Code Online (Sandbox Code Playgroud)
有关相关文档,请参阅协议指南.
| 归档时间: |
|
| 查看次数: |
1639 次 |
| 最近记录: |