2013-07-21 18 views
0

我正在使用Google URL Shortner API https://code.google.com/p/google-api-dotnet-client/wiki/APIs#URL_Shortener_API,並且需要設置quotaUser參數。這應該可以通過service.ServiceParameters字典來實現,而quotaUser已經是字典中的一個鍵,但它是隻讀的,所以我不能將quotaUser的值設置爲我所需要的值。有關如何完成此任何想法?我不明白他們爲什麼會提供字典,但沒有辦法設置它的值。Google URL Shortner API在C#中設置服務參數

回答

1

每個服務請求都包含QuotaUser屬性,因此您可以根據需要進行設置。 例如看在下面的示例代碼:

var service = new UrlshortenerService(new BaseClientService.Initializer() 
      { 
       Authenticator = auth, 
       ApplicationName = "PUT_HERE_YOUR_APP_NAME", 
      }); 
// some code here... 
// create the request set its quota and execute 
var request = service.Url.List(); 
request.QuotaUser = "PUT_HERE_YOUR_QUOTA" 
UrlHistory result = request.Execute(); 

就拿我們UrlshortenerService樣品here一看對於如何使用Urlshortener服務全樣本(我加了QuotaUser財產線後72)