1

我正在编写我的第一个Google API Winforms应用程序,我无法弄清楚如何进行API调用。致电DoubleClick Bid Manager API

这个谷歌“入门”documentation的例子并没有太大的帮助。

我有一个客户端ID和秘密,并已授权我的应用程序使用这些。

ClientSecrets cs = new ClientSecrets { ClientId = "<...>.apps.googleusercontent.com", ClientSecret = "<...>" }; 

var credential = GoogleWebAuthorizationBroker.AuthorizeAsync(cs, new[] { @"https://www.googleapis.com/auth/doubleclickbidmanager" }, "user", 
      System.Threading.CancellationToken.None, new Google.Apis.Util.Store.FileDataStore(@"C:\temp", true)); 

我现在想要调用this API并查看其结果。

有人可以给我指点我该怎么做呢?

回答

1

安装金块包Install-Package Google.Apis.Doubleclickbidmanager.v1

下面的代码应的oauth2

string clientId = "ddd"; 
string clientSecret = "ddd"; 

var credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets { ClientId = clientId, ClientSecret = clientSecret } 
                        , scopes 
                        , "test" 
                        , CancellationToken.None 
                        , new FileDataStore(".",true)).Result; 

    var service = new DoubleClickBidManagerService(new BaseClientService.Initializer() 
     { 
     HttpClientInitializer = credential, 
     ApplicationName = "xyz",  
     }); 

您的所有来电的工作应该去虽然服务

service.Lineitems.Downloadlineitems(body).Execute(); 
+0

@DalmTo您好,感谢您的回答。您可以请我指点一下DoubleClickBidManagerService及其API的一些文档,以便我可以真正了解如何进行所需的所有API调用。 或者如果你有一些示例代码,你可以分享,基本上传和下载的lineitems,这将是伟大的!非常感谢... – ViV

+1

我真的不知道我有什么,我没有双击帐户,所以不能写你的教程抱歉。 – DaImTo

+0

没有问题..我真的很感谢你的帮助。 – ViV