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

问题描述

我搜索了很多关于google fusion table api的东西和网站。 Google提供链接,但我无法理解这个编码及其过程。



请通过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.

推荐答案

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自动更新谷歌融合表!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 11:03