接口文档的提示很模糊,找不到是什么原因所致的。
代码为:
public K DoRequest<T, K>(string methodName, T request) // 其实可以从request得到methodName
{
System.Diagnostics.Debug.Assert(!string.IsNullOrEmpty(methodName) && request != null);
if (methodName == null || request == null)
{
return default(K);
}
if (this.methodName != methodName)
{
this.methodName = methodName;
this.url = GetEndpoint(this.ServiceType, this.methodName);
}
// handle request
JSONEnvelop<AuthHeader, T> reqEnvelop = new JSONEnvelop<AuthHeader, T>(AuthHeaderValue, request);
string reqJson = Serialize<JSONEnvelop<AuthHeader, T>>(reqEnvelop);
//byte[] reqBytes = Compress(reqJson);
byte[] reqBytes = Encoding.UTF8.GetBytes(reqJson);
// actual request
byte[] resBytes = HttpPostService.HttpPost(this.url, this.Timeout, reqBytes, BaiduConfig.ClientId);
// handle response
string resJson = Encoding.UTF8.GetString(resBytes);
JSONEnvelop<ResHeader, K> resEnvelop = DeSerialize<JSONEnvelop<ResHeader, K>>(resJson);
ResHeaderValue = resEnvelop.header;
return resEnvelop.body;
}
返回结果
百度api提示:
901999 Dataitem size is litte than 3 Dataitem size is litte than 3
调用getRealTimeData方法
请求:
返回结果:
调用getCampaign方法
请求:
**返回结果:****
http://www.csdn.net/tag/%E7%99%BE%E5%BA%A6%E6%8E%A8%E5%B9%BF