从SQL API迁移到Fusion Tables v1 [英] Migrating from SQL API to Fusion Tables v1
问题描述
不建议使用SQL API之后,从SQL API迁移的搜索解决方案
https://www.google.com/fusiontables/api/query?sql=
到https://www.googleapis.com/fusiontables/v1/query?sql=
,例如此处
After SQL API was deprecated searching solution to migrate from SQL API
https://www.google.com/fusiontables/api/query?sql=
to https://www.googleapis.com/fusiontables/v1/query?sql=
like here
我得到了:
var URLHead = 'https://www.google.com/fusiontables/api/query?sql='
var URLTable = encodeURI('SELECT id,COUNT() FROM TABLE_ID')
var URLTail = '&access_token='+ TOKEN +'&jsonCallback=?'
var queryURL = URLHead + URLTable + URLTail
var jqxhr = $.get(queryURL, myFT.TABLE, "jsonp")
this.myFT.TABLE = function (DATA) {
var counter = parseInt(DATA.table.rows[0].toString().substr(1))
alert(counter )
}
我需要:
var URLHead = 'https://www.googleapis.com/fusiontables/v1/query?sql='
var URLTable = encodeURI('SELECT id,COUNT() FROM TABLE_ID')
var URLTail = '&access_token='+ TOKEN +'&jsonCallback=?'
var queryURL = URLHead + URLTable + URLTail
var jqxhr = $.get(queryURL, myFT.TABLE, "jsonp")
this.myFT.TABLE = function (DATA) {
var counter = parseInt(DATA.table.rows[0].toString().substr(1))
alert(counter )
}
对于我来说,从SQL API
迁移到/fusiontables/v1/
似乎并不容易.
Looks like it's not so easy to migrate from SQL API
to /fusiontables/v1/
for me.
1.尝试将jsonCallback
更改为callback
-没有帮助!
1. Try to change the jsonCallback
to callback
- not helped!
推荐答案
最后!通过替换jQuery示例,找到了简单的解决方案.与 google-api-javascript-client
别忘了添加到标头中
<script src="https://apis.google.com/js/client.js?onload=load"></script>
Finaly! Found pure and simple solution by replacing jQuery examp. with google-api-javascript-client
Don't forget to add into head tag<script src="https://apis.google.com/js/client.js?onload=load"></script>
myTable1 = new FT('table1_id')
myTable1.run('SELECT * FROM ', myTable1, ' ORDER BY id ASC ')
function FT(table_id)
{
this.counter = 0
this.table = table_id
//
gapi.client.setApiKey('Api_Key')
//
this.run = function (q, cls, order)
{
gapi.client.load('fusiontables', 'v1', function(){
var request = gapi.client.fusiontables.query.sqlGet({'sql': q + cls.table + order});
request.execute(function(DATA){cls.exec(DATA)});
});
}
//
this.exec = function (DATA)
{
alert(DATA.result.rows.length)
}
}
或者就像上面的第一个示例一样,更改此内容
var URLTable = encodeURI('SELECT id,COUNT() FROM TABLE_ID')
对此
var URLTable = encodeURI('SELECT COUNT() FROM TABLE_ID')
Or simply just like in first example above change this
var URLTable = encodeURI('SELECT id,COUNT() FROM TABLE_ID')
to this
var URLTable = encodeURI('SELECT COUNT() FROM TABLE_ID')
这篇关于从SQL API迁移到Fusion Tables v1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!