Javascript 使用jquery获取Google文档电子表格的JSON数据而不公开文档的任何方法?
我正在尝试使用javascript和jQuery从GoogleDoc电子表格中获取数据,以便对数字进行计算 下一个代码是关于公共电子表格的:Javascript 使用jquery获取Google文档电子表格的JSON数据而不公开文档的任何方法?,javascript,jquery,json,google-docs,google-docs-api,Javascript,Jquery,Json,Google Docs,Google Docs Api,我正在尝试使用javascript和jQuery从GoogleDoc电子表格中获取数据,以便对数字进行计算 下一个代码是关于公共电子表格的: function getdata( key, wid, f ) { return $.getJSON( '//spreadsheets.google.com/feeds/cells/' + key + '/' + wid + '/public/basic?alt=json-in-script&callbac
function getdata( key, wid, f )
{
return $.getJSON(
'//spreadsheets.google.com/feeds/cells/' +
key + '/' + wid + '/public/basic?alt=json-in-script&callback=?',
function( data ){
/* the content of this function is not important to the question */
var entryidRC = /.*\/R(\d*)C(\d*)/;
var retdata = {};
retdata.mat = {};
for( var l in data.feed.entry )
{
var entry = data.feed.entry[ l ];
var id = entry.id.$t;
var m = entryidRC.exec( id );
var R,C;
if( m != null )
{
R = new Number( m[ 1 ] );
C = new Number( m[ 2 ] );
}
var row = retdata.mat[ R ];
if( typeof( row ) == 'undefined' )
retdata.mat[ R ] = {};
retdata.mat[ R ][ C ] = entry.content;
}
if( typeof( f ) != 'undefined' )
f( retdata )
else
console.log( retdata );
}
);
}
当我尝试使用私有数据时,我得到了XML格式的数据(使用URL:
'//spreadsheets.google.com/feeds/cells/'+key+'/'+wid+'/private/basic'
)。此测试还检查当前用户的可用性、防火墙、权限设置和登录状态
但是添加最后一部分:?在script&callback=f中alt=json以获取json中的数据,会抛出一个notfound错误404。(如果仅添加了alt=json
,也会得到)
情况摘要:
public private
XML yes yes
JSON yes Question
中描述了针对google使用JSON
中介绍了google电子表格api的使用
使用javascript获取GDoc电子表格的JSON数据而不公开文档的任何方法?
提前感谢
不好意思,因为这是一个非常有用的特性。事实上,我很高兴知道这至少在已发布的文档中是可能的。这是我的第一个问题,请投票/评论,以便我可以改进我的风格。&callback=f
可能是一个打字错误,你的意思是&callback=?
当我在浏览器的地址栏中时,我使用=f
,从jquery我使用=?
。无论如何,谢谢。“注意:只有已发布的电子表格才支持在没有身份验证的情况下检索提要。”~~非常感谢您的回答!至少我可以停止搜索。请发布一个答案,这样我就可以接受它,并将问题标记为已解决,因为它将对将来的人有用。