使用C#.net自动更新谷歌融合表! [英] Using C#.net update google fusion tables automatically!

查看:64
本文介绍了使用C#.net自动更新谷歌融合表!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我搜索了很多关于google fusion table api的东西和网站。 Google提供 https://developers.google.com/fusiontables/docs/developers_guide#CreatingTable 链接,但我无法理解这个编码及其过程。



请通过C#.net代码自动使用Web链接给我一个关于更新google fusion表的清晰示例代码。

I had searched lot of things and site about google fusion table api. Google provide "https://developers.google.com/fusiontables/docs/developers_guide#CreatingTable" this link but i am unable to understand this coding and its process.

Kindly give me a clear sample code about update google fusion tables automatically using web link through C#.net code.

推荐答案





如果你不明白,给你提供示例代码几乎没用Google使用了什么技术。

正如google所提到的,fusion api是基于http和json构建的,所以你应该与 GET 相似和 POST 方法。



首先,要使用此API,您必须使用 HttpWebResponse HttpWebRequest C#中的方法。



示例代码POST:



Hi,

it's nearly useless to give you sample code if you don't understand what technology is used by Google.
As mentioned by google, the fusion api is build on http and json,so you should be fimilar with GET and POST Methods.

For a starting point, to use this API you have to work with HttpWebResponse and HttpWebRequest Methods in C#.

Example code POST:

private String executeUpdate(String query, String token) {
    string sdata = "sql=" + HttpUtility.UrlEncode(query);
    ASCIIEncoding encoding = new ASCIIEncoding();
    byte[] data = encoding.GetBytes(sdata);

    // Create the request, encode the query in the body of the post
    HttpWebRequest req = (HttpWebRequest)
      WebRequest.Create("http://tables.googlelabs.com/api/query");
    req.Method = "POST";
    req.ContentType="application/x-www-form-urlencoded";
    req.ContentLength = data.Length;

    // Add the authentication header
    req.Headers.Add("Authorization: GoogleLogin auth=" + token);

    Stream sout = req.GetRequestStream();
    sout.Write(data, 0, data.Length);
    sout.Close();

    try {
      HttpWebResponse res = (HttpWebResponse) req.GetResponse();
      StreamReader stIn = new  StreamReader(res.GetResponseStream());
      return stIn.ReadToEnd();
    }  catch (WebException e) {
      StreamReader stIn = new  StreamReader(e.Response.GetResponseStream());
      return stIn.ReadToEnd();
    }
  }





请参阅googles fusion libs 这里



干杯



See googles fusion libs here.

Cheers


这篇关于使用C#.net自动更新谷歌融合表!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆