我想使用java从我的Android应用数据库中将数据插入到谷歌融合表中

时间:2015-02-18 14:52:19

标签: java android google-fusion-tables

我在android中创建一个应用程序,我通过表单收集数据并将其保存在内部存储器中的SQLite数据库中。然后我从数据库中获取所有数据,我想将所有数据插入到我创建的Google Fusion Table中。我在谷歌控制台创建了一个项目并启用了融合表api。我也为我的应用程序生成了OAuth client_id和api密钥。

现在我尝试通过HttpPost发送插入查询。但我得到403错误代码。

{
 "error": {
  "errors": [
   {
    "domain": "usageLimits",
    "reason": "ipRefererBlocked",
    "message": "There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed.",
    "extendedHelp": "https://console.developers.google.com"
   }
  ],
  "code": 403,
  "message": "There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed."
 }
}

这是代码snipet。

public void insertService(String query) {
    String url = URL + "?sql=" + query + "&key=AIzaSyDD7eZrdhxl7QjTJHgu4thZ-OJZgTOIDXQ";
    HttpClient client = new DefaultHttpClient();
    HttpPost httpPost = new HttpPost(url);
    try {
        HttpResponse response = client.execute(httpPost);
        // ....

Fusion Table没有足够的教程或文档。我已经浏览了谷歌文档,但仍然没有找到任何解决方案。 我应该使用OAuth,如果是这样,如何在java中使用它,因为从文档中不清楚。如果有人知道请一步一步解释我。 请帮助我,我需要尽快完成这个。

提前致谢。

0 个答案:

没有答案