ComScore学习(二)

 主要研究几个方面:
1.获取提交请求所需要的参数
 Submit主要需要提供Geo、Loc、TimeType、TimePeriod、Media及Measure这6个参数,但是每个参数又存在依赖关系,需要创建查询实例后才能获取下个参数,其中Media和Measure比较特殊些 

2.Submit Report

//一、获得KeyMeasures报告的服务对象
KeyMeasures service=new KeyMeasures();
//获得权限
service.Credentials = new System.Net.NetworkCredential("msn_aomediaapi", "7bfd8");
//二、获得KeyMeasures的查询对象
query oQuery=new query();
//三、填充查询对象的参数值
//1.获得要查询的报告的参数值:要查询哪方面的数据?
//1.1 geo
DiscoverParameterValuesResult geoValues = service.DiscoverParameterValues("geo", oQuery);
//1.11存储到本地变量中
queryParameter oQueryParamGeo= new queryParameter {KeyId = "geo", Value = geoValues.EnumValue[0].Id};
//1.12 为loc参数提供实例
oQuery.Parameter = new[] {oQueryParamGeo};
//2.1 loc
DiscoverParameterValuesResult locValues= service.DiscoverParameterValues("loc", oQuery);
queryParameter oQueryParameterLoc= new queryParameter {KeyId = "loc", Value = locValues.EnumValue[0].Id};
//3.1 timeType
DiscoverParameterValuesResult timeTypeValues= service.DiscoverParameterValues("timeType", oQuery);
queryParameter oQueryParameterTimeType= new queryParameter {KeyId = "timeType", Value = timeTypeValues.EnumValue[0].Id};
//3.11 为timePeriod参数提供实例
oQuery.Parameter = new[] {oQueryParamGeo, oQueryParameterTimeType};
//4.1 timePeriod
DiscoverParameterValuesResult timePeriodValues= service.DiscoverParameterValues("timePeriod", oQuery);
queryParameter oQueryParameterTimePeriod = new queryParameter();
oQueryParameterTimePeriod.KeyId = "timePeriod";
oQueryParameterTimePeriod.Value = timePeriodValues.EnumValue[0].Id;
//4.11 为media参数提供实例
//4.111 targetType
queryParameter oQueryParameterTargetType=new queryParameter();
oQueryParameterTargetType.KeyId = "targetType";
oQueryParameterTargetType.Value = "0";
//4.112
oQuery.Parameter = new[] { oQueryParamGeo, oQueryParameterTimeType, oQueryParameterTimePeriod };
//4.113 targetGroup
DiscoverParameterValuesResult targetGroupValues = service.DiscoverParameterValues("targetGroup", oQuery);
queryParameter oQueryParameterTargetGroup=new queryParameter();
oQueryParameterTargetGroup.KeyId = "targetGroup";
oQueryParameterTargetGroup.Value = targetGroupValues.EnumValue[0].Id;

oQuery.Parameter=new queryParameter[]{oQueryParamGeo,oQueryParameterTimeType,oQueryParameterTimePeriod};
//4.114 mediaSetType
DiscoverParameterValuesResult mediaSetTypeValues = service.DiscoverParameterValues("mediaSetType", oQuery);
//4.115 fetchMedia
fetchMediaQuerySearchCritera searchCritera=new fetchMediaQuerySearchCritera();
searchCritera.Critera = "google";

fetchMediaQuery mMediaquery=new fetchMediaQuery();
mMediaquery.SearchCritera = new[] {searchCritera};

reportQueryParameter rqp1=new reportQueryParameter();
rqp1.KeyId = "geo";
rqp1.Value = geoValues.EnumValue[0].Id;

reportQueryParameter rqp2=new reportQueryParameter();
rqp2.KeyId = "timeType";
rqp2.Value = timeTypeValues.EnumValue[0].Id;

reportQueryParameter rqp3=new reportQueryParameter();
rqp3.KeyId = "timePeriod";
rqp3.Value = timePeriodValues.EnumValue[0].Id;

reportQueryParameter rqp4=new reportQueryParameter();
rqp4.KeyId = "mediaSetType";
rqp4.Value = mediaSetTypeValues.EnumValue[0].Id;

reportQuery mrReportQuery=new reportQuery();
mrReportQuery.Parameter=new reportQueryParameter[]{rqp1,rqp2,rqp3,rqp4};

//5.1 media
FetchMediaResult mResult1 = service.FetchMedia("media", mMediaquery, mrReportQuery);
queryParameter oQueryMedia=new queryParameter();
oQueryMedia.KeyId = "media";
oQueryMedia.Value = mResult1.MediaItem[0].Id;

//oQuery.Parameter = new[]
// {oQueryParamGeo, oQueryParameterTimeType, oQueryParameterTimePeriod, oQueryParameterMedia};
//6.1 measure
DiscoverParameterValuesResult measureValue = service.DiscoverParameterValues("measure", oQuery);
queryParameter oQueryParameterMeasure1 = new queryParameter
{
KeyId = "measure",
Value = measureValue.EnumValue[0].Id
};
queryParameter oQueryParameterMeasure2 = new queryParameter
{
KeyId = "measure",
Value = measureValue.EnumValue[1].Id
};
oQuery.Parameter = new[] {oQueryParamGeo,oQueryParameterLoc,oQueryParameterTimeType,oQueryParameterTimePeriod,oQueryParameterTargetType,oQueryParameterTargetGroup,oQueryMedia,oQueryParameterMeasure1,oQueryParameterMeasure2};


SubmitReportResult qrResult= service.SubmitReport(oQuery);
string result = XMLHelper<SubmitReportResult>.Serialize(qrResult);
return Content(result);


3.获得某个report的状态
4.获得所有report的信息
5.获取完成report的结果 

你可能感兴趣的:(core)