# -*-coding:utf-8 -*-
import re
import datetime
import requests
import json
import urllib
import sys
import hashlib
import base64
# reload(sys)
# sys.setdefaultencoding('utf8')

a=sys.getdefaultencoding()
print a

#request_url = "http://testapi.kdniao.cc:8081/Ebusiness/EbusinessOrderHandle.aspx"
request_url = "http://api.kdniao.cc/Ebusiness/EbusinessOrderHandle.aspx"
user_ID='1311276'
API_key='fba93f3f-bf15-41b8-8f33-e47751e6c2e6'

requestData = '{"LogisticCode":"887093117556741105"}'
requestData_utf8 = urllib.quote_plus(requestData)
print requestData_utf8

m = hashlib.md5()
m.update(requestData + API_key)
requestData_md5 = m.hexdigest()
print requestData_md5
    
requestData_md5_base64 = base64.b64encode(requestData_md5)
print requestData_md5_base64

requestData_md5_base64_uft8 = urllib.quote_plus(requestData_md5_base64)
print requestData_md5_base64_uft8

params = {
	"RequestType":'2002',
	"RequestData":requestData_utf8,
	"DataType":"2",
	"DataSign":requestData_md5_base64_uft8,
	"EBusinessID":user_ID
    }
response = requests.post(request_url,params=params)
print params
print type(response)
for a in response:
	print a