我正在尝试获取 Google 分析的基本网址,但由于某种原因我无法让它工作 - 我尝试了以下方法:
//this is the old url and did use to work ( see `//https://developers.google.com/analytics/devguides/reporting/core/v2/ )`
//const string baseUrl = "https://www.google.com/analytics/feeds/data";
// this is also outdated
//const string baseUrl = "https://www.googleapis.com/analytics/v2.4/data";
// this doesnt seem to work!!!
const string baseUrl = "https://www.googleapis.com/analytics/v3/data";
这是我编写的一些代码,应该构建 url
const string baseUrl = "https://www.googleapis.com/analytics/v3/data/";
var retailers = affiliateRetailerRepository.GetAffiliateRetailerByScheme(affiliateScheme.Id);
foreach (var affiliateRetailer in retailers)
{
var query = new DataQuery(baseUrl)
{
Ids = affiliateRetailer.Code,
//todo - custom var may neeed to be put back Dimensions = "ga:customVarName(n),transactionId,ga:productName,ga:productSku,ga:date,ga:hour",
Dimensions = "transactionId,ga:productName,ga:productSku,ga:date,ga:hour",
//Metrics = "ga:itemRevenue,ga:revenuePerItem,ga:itemQuantity",
Metrics = "ga:itemRevenue,ga:itemQuantity",
Segment = "gaid::-8",
Filters = filters,
GAStartDate = startDate.ToString("yyyy-MM-dd"),
GAEndDate = endDate.ToString("yyyy-MM-dd"),
NumberToRetrieve = 10000
};
Uri url = query.Uri;
使用上面我得到以下http:
{https://www.googleapis.com/analytics/v3/data/?max-results=10000&dimensions=transactionId,ga:productName,ga:productSku,ga:date,ga:hour&end-date=2012-08-28&filters= ga:source=@where-to-buy.co,ga:source=@where-to-purchase.us,ga:source=@where-to-buy.fr,ga:source=@wheretopurchase.de,ga: source=@where-to-buy.es,ga:source=@wheretopurchase.it,ga:source=@where-to-purchase.ru,ga:source=@where-to-buy.pl,ga:source= @where-to-buy.se,ga:source=@where-to-buy.nl,ga:source=@where-to-purchase.us,ga:source=@wheretopurchase.ca&ids=ga:57437629&metrics=ga: itemRevenue,ga:itemQuantity&start-date=2012-03-13&segment=gaid::-8}
我知道我的代码腐烂了,因为我已经有一段时间没有看过这段代码了,但是如果有人有任何建议 - 我认为这只是将基本 url 更改为最新的,但事实并非如此似乎工作。
任何帮助表示赞赏。
编辑:或者只是如果有人有一个工作 url,我可以用它来构建我的,这也很有用,因为我提到这是不久前放在一起的,所以这可能意味着我需要根据新的 API 格式重新格式化整个代码所以看到一个有用的,然后我可以根据我的需要定制它。谢谢