从.net更新融合表
你好,我正在寻找一个如何从asp.net web项目更新google fusion表的示例。这在过去是可能的,通过发出httpwebrequest,谷歌似乎已经改变了他们的api,我发现的例子不再有效 另一方面,谷歌发布了一个.net客户端来访问谷歌API 但我找不到如何更新融合表的工作示例。这个人也面临着同样的问题 任何帮助都将不胜感激从.net更新融合表,.net,google-fusion-tables,.net,Google Fusion Tables,你好,我正在寻找一个如何从asp.net web项目更新google fusion表的示例。这在过去是可能的,通过发出httpwebrequest,谷歌似乎已经改变了他们的api,我发现的例子不再有效 另一方面,谷歌发布了一个.net客户端来访问谷歌API 但我找不到如何更新融合表的工作示例。这个人也面临着同样的问题 任何帮助都将不胜感激 谢谢我想你是在问如何插入数据。以下是一个例子: string timestamp = DateTime.Now.ToString("u").TrimEnd
谢谢我想你是在问如何插入数据。以下是一个例子:
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();
我正在使用一个服务帐户;融合台是这样设置的
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,因为这对我的应用程序很有意义