diff --git a/README.md b/README.md index 2cb3544342e03438b6da5c2e643ee679c1220ce4..7980d463d61ccbec9e241586a36e1f319233cf48 100644 --- a/README.md +++ b/README.md @@ -181,3 +181,20 @@ gr.setParams(goodsId="2222112") data=gr.getResponse() print(data) + +**** +`通用req方法` + +appKey = 'xxx' + +appSecret = 'xxx' + +version = 'v1.0.1' + +req = DefaultReq(appKey, appSecret, version) + +req.setParams(url="tb-service/parse-content", method="GET", params={"content": "4$Y2tMdfT9OZ5$:// ZH9114"}) + +data = req.getResponse() + +print(data) \ No newline at end of file diff --git a/dtkApi/basic/DefaultReq.py b/dtkApi/basic/DefaultReq.py new file mode 100644 index 0000000000000000000000000000000000000000..cc227335cc985e5865a3b47e206a188a367b6d60 --- /dev/null +++ b/dtkApi/basic/DefaultReq.py @@ -0,0 +1,18 @@ +# -*- coding:utf8-*- + +from dtkApi.apiRequest import Request + + +# 加了签名校验的默认请求 +class DefaultReq(Request): + url = '' + method = "GET" + + # GET请求 + def getResponse(self): + return self.request(self.method, api_url=self.url, args=self.params) + + def setParams(self, url, method="GET", params={}): + self.url = url + self.method = method + self.params = params diff --git a/dtkApi/basic/__init__.py b/dtkApi/basic/__init__.py index 8e20c9d086faaef18f1328fe91e41c7517b4fc23..5e34fff8d4dd14c90e4b2fe168813ba8648f60c9 100644 --- a/dtkApi/basic/__init__.py +++ b/dtkApi/basic/__init__.py @@ -58,6 +58,6 @@ from dtkApi.basic.TbGoodsCouponReq import TbGoodsCouponReq from dtkApi.basic.TbShopConvertReq import TbShopConvertReq from dtkApi.basic.PddGoodsCategoryReq import PddGoodsCategoryReq from dtkApi.basic.JdGoodsCategoryReq import JdGoodsCategoryReq - +from dtkApi.basic.DefaultReq import DefaultReq