淘宝API举例子

# -*- coding: utf-8 -*-

import urllib2
import urllib
import time
import md5

secret=‘xxxxx
app_key=‘yyyy
session =‘zzzzzz

arg={
    format: json,
    timestamp:  time.strftime(%Y-%m-%d %H:%M:%S),
    app_key: app_key,
    v : 2.0,
    sign_method: md5,
    session :session,
    
    method: taobao.trades.sold.get,
    fields: seller_nick,buyer_nick,   #   taobao.trades.sold.get 方法用到的应用参数,
    type:tmall_i18n,                      #    taobao.trades.sold.get 方法用到的应用参数, 
}
keys = arg.keys()
keys.sort()

str=‘‘
#参数排序后连接字串 ‘k‘+‘v‘
for k in keys:
    str+=k +arg[k]
#首尾加上 secret
str= secret + str + secret
#md5编码后转大写
sign=md5.md5(str).hexdigest().upper()


postDict = arg.copy()
#rul 请求加上 签名
postDict.update( {sign: sign}  )
postData = urllib.urlencode(postDict);
req = urllib2.Request(http://gw.api.taobao.com/router/rest, postData);
resp = urllib2.urlopen(req)

print  resp.read()

 

淘宝API举例子,布布扣,bubuko.com

淘宝API举例子

上一篇:Using the Windows Scheduler to run a SharePoint PowerShell Backup Script


下一篇:PS光影表现为照片增添艺术效果