pid格式
pid = mm_memberId_siteId_adzoneId
mm_1234_5434_49949
网站
-
官方网站:
https://open.taobao.com
需申请对应的权限限制较多
接口加密算法
#/usr/bin/python
# -*- coding: utf-8 -*-
import requests
import hashlib
import time
class TaoBaoKe:
def __init__(self, appKey, appSecret, host="http://gw.api.taobao.com:80/router/rest"):
self.appKey = appKey
self.appSecret = appSecret
self.host = host
def request(self, method, body=None, headers={'Content-type': 'application/x-www-form-urlencoded;charset=UTF-8', 'Cache-Control': 'no-cache', 'Connection': 'Keep-Alive'}):
urlParams = {
'format': 'json',
'app_key': self.appKey,
'sign_method': 'md5',
'v': '2.0',
'timestamp': str(int(time.time())),
'method': method
}
urlParams.update(body)
urlParams["sign"] = self._sign(self.appSecret, urlParams)
res = requests.post(self.host, params=urlParams, data=body, headers=headers)
return res
def _sign(self, secret, parameters):
#===========================================================================
# '''签名方法
# @param secret: 签名需要的密钥
# @param parameters: 支持字典和string两种
# '''
#===========================================================================
# 如果parameters 是字典类的话
if hasattr(parameters, "items"):
keys = sorted(parameters.keys())
parameters = "%s%s%s" % (secret,
str().join('%s%s' % (key, parameters[key]) for key in keys),
secret)
sign = hashlib.md5(parameters.encode("utf-8")).hexdigest().upper()
return sign
appKey = "27947023"
appSecret = "eab32c079165c223886a311e7f92789"
tb = TaoBaoKe(appKey, appSecret)
res = tb.request("taobao.tbk.tpwd.parse", {"password_content":"p3gr1pF6Bun"})
print(res.json())
网友评论