从.net更新融合表 [英] Update fusion table from .net
问题描述
Good Day im正在寻找一个示例,该示例如何从asp.net Web项目更新Google融合表.过去可以通过创建httpwebrequest来实现,这似乎是Google更改了其api,而我发现的示例不再起作用.
Good Day im looking for an example of how to update a google fusion table form a asp.net web project. This was possible in the past through making an httpwebrequest, it seems google has changed their api's and the examples i found no longer works.
从好的方面来说,谷歌已经发布了一个.net客户端来访问Google API. https://code.google.com/p/google-api-dotnet -client/
On the plus side Google has released a .net client to access the google apis https://code.google.com/p/google-api-dotnet-client/
但是我找不到如何更新融合表的工作示例.这个人也面临着同样的问题
but i cannot find a working sample of how to update a fusion table. This person is also facing the same problem
发布使用VB.NET对新Fusion Table API v1.0的请求
任何帮助将不胜感激
谢谢
推荐答案
我认为您在问如何插入数据.这是一个示例:
I think you are asking how to insert data. Here is an example:
string timestamp = DateTime.Now.ToString("u").TrimEnd('Z'); //e.g. 2008-04-10 13:30:00
string sql = "INSERT INTO " + tableId + " (Timestamp, MAC_Address, URL) VALUES ('" + timestamp + "','" + macAddress + "','" + url + "')" ;
var response = fusiontablesService.Query.Sql( sql ).Execute();
我正在使用服务帐户;融合表是这样设置的
I'm using a Service Account; the fusion table is set up like this
private void InitializeFusiontables()
{
//uses a service account; the fusiontable is shared with the service account's email address
//https://code.google.com/p/google-api-dotnet-client/wiki/OAuth2
var certificate = new X509Certificate2( privateKeyFile, "notasecret", X509KeyStorageFlags.Exportable);
ServiceAccountCredential credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(serviceAccountEmail)
{
Scopes = new[] { FusiontablesService.Scope.Fusiontables }
}.FromCertificate(certificate));
// Create the service.
fusiontablesService = new FusiontablesService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "snarf-service-2", //not sure if the name here matters or not
});
this.dataTable = fusiontablesService.Table.Get(tableId).Execute(); //.List().Execute();
eventLog.WriteEntry("Fusiontable successfully located");
macAddress = "testmacaddress";
InsertRow("testurl.com");
}
我对tableId进行了硬编码,因为这对我的应用程序很有意义.
I hard coded the tableId because that makes sense for my application.
这篇关于从.net更新融合表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!