这会编译,但不会为我返回任何数据。
授权:
public static WebmastersService WMAuthenticateOauth(string clientId, string clientSecret, string userName)
{
string[] scopes = new string[] { WebmastersService.Scope.Webmasters };
try
{
UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets { ClientId = clientId, ClientSecret = clientSecret }
, scopes
, userName
, CancellationToken.None
, new FileDataStore(".", true)).Result;
WebmastersService service = new WebmastersService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "WebMasters API Sample",
});
return service;
}
catch (Exception ex)
{
Console.WriteLine(ex.InnerException);
return null;
}
}
要求
var service = Authentcation.WMAuthenticateOauth(clientid, secret, "testmmm");
IList<string> newlist = new List<string> ();
newlist.Add("country");
newlist.Add("device");
SearchAnalyticsQueryRequest body = new SearchAnalyticsQueryRequest();
body.StartDate = "2015-04-01";
body.EndDate = "2015-05-01";
body.Dimensions = newlist;
var result = service.Searchanalytics.Query(body, "http://www.daimto.com/").Execute();
我也尝试过使用底部的try me进行测试
page
。它也不会返回任何内容。
奇怪的API。
更新:
我终于拿回了数据,我把日期设定为
身体开始日期=“2015-09-01”;
身体结束日期=“2015-09-15”;
我想知道这件事的数据是否有限,它只能追溯到目前为止。