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