申请完成应用之后,登录open.taobao.com找到应用,下载SDK后引入到自己的项目工程中,进行测试,主要用的到的系统级参数
1.appkey,secret(应用详情中查看[沙箱,正式])
2.sessionkey(店铺授权给appkey应用,生成sessionkey,表示允许此appkey可以访问此店铺中的数据),1个appkey可对应多个店铺(每个店铺对应一个sessionkey)
正式环境获取session key地址:[授权地址]:【//open.taobao.com/apitools/sessionPage.htm?spm=0.0.0.0.5Fhlji,】 输入appkey之后提交对应的店铺帐户登录生成sessionkey (授权前一定要在应用基本信息里设置的回调URL,不设置授权会报错-无效的回调地址)
3.url网关地址:
正式环境:http://gw.api.taobao.com/router/rest
沙箱环境:http://gw.api.tbsandbox.com/router/rest(沙箱环境不稳定,建议直接使用正式环境)
1.class Baseinfo {
String strUrl = "";
String strAppkey = "";
String strSessionKey = "";
String strSecret = "";
public Baseinfo()
{
/*
* 沙箱测试参数
* seller_nick=sandbox_04
* 正式环境使用请替换参数
*/
strUrl = "http://gw.api.tbsandbox.com/router/rest";
strAppkey = "1023040450";
strSecret = "sandbox2a6cc1895eb6ca6b2eaf4e147";
strSessionKey = "61023246bac9c9d9c581bb573ecd24db14afd516ae08bda3637225472";
}
}
2.public static void GetOrderList()
{
Baseinfo jipiaobase = new Baseinfo();
TaobaoClient client=new DefaultTaobaoClient(jipiaobase.strUrl, jipiaobase.strAppkey, jipiaobase.strSecret);
AlitripIeAgentOrderSearchRequest req = new AlitripIeAgentOrderSearchRequest();
try
{
Date dateTimebegin = SimpleDateFormat.getDateTimeInstance().parse("2014-07-15 21:15:59");
req.setBeginTime(dateTimebegin);
req.setCurrentPage(1L);
Date dateTimeend = SimpleDateFormat.getDateTimeInstance().parse("2015-07-16 22:15:59");
req.setEndTime(dateTimeend);
req.setOrderStatus("PaySuccess");//订单状态只能传入一种
req.setPageSize(20L);
req.setAgentId(1511L);
AlitripIeAgentOrderSearchResponse response = (AlitripIeAgentOrderSearchResponse)CommonMethod(jipiaobase,client,req);
if(response.getErrorCode() != null)
{
System.out.println("ErrorCode="+response.getErrorCode()+";ErrorMsg="+response.getMsg()
+";SubCode="+response.getSubCode()+";SubMsg="+response.getSubMsg());
}
else
{
System.out.println("body="+response.getBody());
}
}
catch(Exception e)
{
System.out.println(" ***Error Detail*** ");
e.printStackTrace();
}
}