原文地址:http://forum.alisoft.com/read.php?tid=22236
class AliMain(webapp.RequestHandler):
def get(self):
# get all param
aliurl = "http://sipdev.alisoft.com/sip/rest"
appid = self.request.get('app_id')
instanceid = self.request.get('app_instance_id')
target = self.request.get('target')
token = self.request.get('token')
userid = self.request.get('user_id')
timestamp = strftime("%Y-%m-%d %H:%M:%S")
sessionid = '777'
# calculate the signature
data = '1111111111111111111111111'+'appId'+appid \
+'appInstanceId'+instanceid+'sip_apinamealisoft.validateUser' \
+'sip_appkey'+appid+'sip_sessionid'+sessionid \
+'sip_timestamp'+timestamp \
+'token'+token \
+'userId'+userid
coder = md5.new()
coder.update(data)
digest = coder.hexdigest()
# send the auth request
form_fields = {
'sip_timestamp': timestamp,
'sip_appkey': appid,
'appId': appid,
'token': token,
'appInstanceId': instanceid,
'userId': userid,
'sip_apiname': 'alisoft.validateUser',
'sip_sessionid': sessionid,
'sip_sign': digest
}
form_data = urllib.urlencode(form_fields)
result = urlfetch.fetch(url=aliurl,
payload=form_data,
method=urlfetch.POST,
headers={'Content-Type': 'application/x-www-form-urlencoded'})
self.response.out.write(result.content)
ps:我早点找到,多好啊。。。
class AliMain(webapp.RequestHandler):
def get(self):
# get all param
aliurl = "http://sipdev.alisoft.com/sip/rest"
appid = self.request.get('app_id')
instanceid = self.request.get('app_instance_id')
target = self.request.get('target')
token = self.request.get('token')
userid = self.request.get('user_id')
timestamp = strftime("%Y-%m-%d %H:%M:%S")
sessionid = '777'
# calculate the signature
data = '1111111111111111111111111'+'appId'+appid \
+'appInstanceId'+instanceid+'sip_apinamealisoft.validateUser' \
+'sip_appkey'+appid+'sip_sessionid'+sessionid \
+'sip_timestamp'+timestamp \
+'token'+token \
+'userId'+userid
coder = md5.new()
coder.update(data)
digest = coder.hexdigest()
# send the auth request
form_fields = {
'sip_timestamp': timestamp,
'sip_appkey': appid,
'appId': appid,
'token': token,
'appInstanceId': instanceid,
'userId': userid,
'sip_apiname': 'alisoft.validateUser',
'sip_sessionid': sessionid,
'sip_sign': digest
}
form_data = urllib.urlencode(form_fields)
result = urlfetch.fetch(url=aliurl,
payload=form_data,
method=urlfetch.POST,
headers={'Content-Type': 'application/x-www-form-urlencoded'})
self.response.out.write(result.content)
ps:我早点找到,多好啊。。。