Example #1
0
def signin(action, params):
    gkey = params.get('gkey')
    key = strutil.md5digest('%s%s' % (gkey, action))
    sstr = '%s%s%s%s%s#%s' % (params.get('uid'),
                              gkey,
                              params.get('skey'),
                              params.get('time'),
                              params.get('matchid'),
                              key)
    return strutil.md5digest(sstr)
Example #2
0
 def _calcSign(self, params):
     kvs = []
     for key in sorted(params.keys()):
         kvs.append('%s=%s' % (key, params[key]))
     kvs.append(self.secretKey)
     signstr = ''.join(kvs)
     return strutil.md5digest(signstr)
Example #3
0
def _signForWeixin(params):
    keys = sorted(params.keys())
    checkstr = ''
    for k in keys:
        checkstr += k + '=' + params[k] + '&'
    checkstr = checkstr[:-1]

    apikey = 'www.tuyoo.com-api-6dfa879490a249be9fbc92e97e4d898d-www.tuyoo.com'
    checkstr = checkstr + apikey
    return strutil.md5digest(checkstr)
Example #4
0
def _signForWeixin(params):
    keys = sorted(params.keys())
    checkstr = ''
    for k in keys:
        checkstr += k + '=' + params[k] + '&'
    checkstr = checkstr[:-1]

    apikey = 'www.tuyoo.com-api-6dfa879490a249be9fbc92e97e4d898d-www.tuyoo.com'
    checkstr = checkstr + apikey
    return strutil.md5digest(checkstr)
Example #5
0
 def _buildSign(cls, params, secret):
     '''(utf-8编码)
     1.根据参数名排序
     2.参数名和参数值拼装
     3.计算md5值,并转为16进制大写字符串表示
     @param params: 除了sign之外,其他的所有参数
     '''
     param_keys = params.keys()
     param_keys.sort()
     params_joined = ''
     for key in param_keys:
         params_joined += key + str(params[key])
     params_joined += secret
     return strutil.md5digest(params_joined.encode('utf-8')).upper()
Example #6
0
def checkHttpParamCode(appKey, codeKey='code'):
    request = getRequest()
    args = request.args
    ftlog.debug('checkHttpParamCode->', args)
    rparam = {}
    for k, v in args.items():
        rparam[k] = v[0]
    code = rparam[codeKey]
    del rparam[codeKey]
    signStr = _createLinkString(rparam)
    md5code = strutil.md5digest(str(appKey) + signStr + str(appKey))
    if md5code != code:
        return False
    return True
Example #7
0
def checkCode(params):
    code = ''
    if 'code' in params:
        code = params['code']
        del params['code']
    
    sk = sorted(params.keys())
    strs = ['%s=%s' % (k, str(params[k]).strip()) for k in sk]
    cstr = '&'.join(strs)
    cstr += API_KEY
    if code != strutil.md5digest(cstr):
        return -1, 'Verify code error'

    acttime = int(params.get('time', 0))
    if abs(pktimestamp.getCurrentTimestamp() - acttime) > 10:
        return -1, 'verify time error'
    return 0, None
Example #8
0
    def _doLogin(self):
        loginur = gdata.httpSdkInner() + '/open/v3/user/processSnsId'
        params = {'svninfo': '$robot$',
                  'appId': str(self.gameId),
                  'ty_bindmobile': '',
                  'phoneType': '',
                  'imei': ['Xb6tiNAVcw5eLrd1F4JTW2dnDrGNr3P0EXl2x99NUeVYGHCQB6ECeQ=='],
                  'iccid': ['RcjQJPkcLGfazgYaKJGWd8hTMfWp8OVr86NEoHuo1C0fIaCKUsTAhuB7huInoqWf'],
                  'androidId': ['BwyJv/PH1UCPjZDob4BSPgiwpuTq4dYgt1OFMrAoLJTED4oxlxdnEtuXKiOJxpkV'],
                  'snsToken': '',
                  'mac': ['wn+rGmlh6/AG6S6O+7kew0ZaMHsfR0LstUtr/WOvXtX681nrM5c+406L0PvY3P7W'],
                  'ty_uid': '0',
                  'clientId': self.clientId,
                  'deviceName': self.name,
                  'snsId': strutil.tyDesEncode(self.snsId),
                  'deviceId': ''
                  }
        sigstr = ''
        pkeys = params.keys()
        pkeys.sort()
        for k in pkeys:
            sigstr = sigstr + str(k) + '=' + str(params[k]) + '&'
        sigstr = sigstr[:-1]
        code = strutil.md5digest(strutil.tyDesEncode(sigstr))
        params['code'] = code

        userInfo, _ = webpage.webget(loginur, params)
        userInfo = strutil.loads(userInfo, ignoreException=True, execptionValue=userInfo)
        if not isinstance(userInfo, dict):
            ftlog.warn('snsId=', self.snsId, 'login-> return error !', userInfo)
            self.stop()
            return
        if self.isbusy == 0:  # 已经关闭
            return

        ftlog.debug('snsId=', self.snsId, 'login->', userInfo)

        result = userInfo.get('result', {})
        self.userId = result.get('userId', 0)
        if not isinstance(self.userId, int) or self.userId < 0:
            raise Exception('robot user login false !' + self.snsId)
        ftlog.debug('Robot login ok snsId=', self.snsId, 'userId=', self.userId)
        self.userInfo = result
        self.checkState(CMD_LOGIN)
Example #9
0
    def checkCode(self):
        code = ''
        datas = runhttp.getDict()
        if 'code' in datas:
            code = datas['code']
            del datas['code']
        keys = sorted(datas.keys())
        checkstr = ''
        for k in keys:
            checkstr += k + '=' + datas[k] + '&'
        checkstr = checkstr[:-1]

        apikey = 'www.tuyoo.com--third-party-api-e031f2a946854db29211a20f2252c3a3-www.tuyoo.com'
        checkstr = checkstr + apikey
        if code != strutil.md5digest(checkstr):
            return -1, 'Verify code error'

        acttime = int(datas.get('time', 0))
        if abs(time.time() - acttime) > 10:
            return -1, 'Verify time error'
        return 0, None
Example #10
0
    def checkCode(self):
        code = ''
        datas = runhttp.getDict()
        if 'code' in datas:
            code = datas['code']
            del datas['code']
        keys = sorted(datas.keys())
        checkstr = ''
        for k in keys:
            checkstr += k + '=' + datas[k] + '&'
        checkstr = checkstr[:-1]

        apikey = 'www.tuyoo.com-api-6dfa879490a249be9fbc92e97e4d898d-www.tuyoo.com'
        checkstr = checkstr + apikey
        if code != strutil.md5digest(checkstr):
            return -1, 'Verify code error'

#         acttime = int(datas.get('time', 0))
#         if abs(time.time() - acttime) > 10:
#             return -1, 'verify time error'
        return 0, None
Example #11
0
    def checkCode(self):
        code = ''
        datas = runhttp.getDict()
        if 'code' in datas:
            code = datas['code']
            del datas['code']
        keys = sorted(datas.keys())
        checkstr = ''
        for k in keys:
            checkstr += k + '=' + datas[k] + '&'
        checkstr = checkstr[:-1]

        apikey = 'www.tuyoo.com--third-party-api-e031f2a946854db29211a20f2252c3a3-www.tuyoo.com'
        checkstr = checkstr + apikey
        if code != strutil.md5digest(checkstr):
            return -1, 'Verify code error'

        acttime = int(datas.get('time', 0))
        if abs(time.time() - acttime) > 10:
            return -1, 'Verify time error'
        return 0, None
Example #12
0
                                timeout=conf.get('timeout', 3))
    if ftlog.is_debug():
        ftlog.debug('match360kp.onPlayerOver userId=', event.userId,
                    'matchId=', event.matchId, 'signinParams=',
                    event.player.signinParams, 'snsId=', event.player.snsId,
                    'conf=', conf, 'result=', result)

    if not result or 'errno' in result:
        ftlog.warn('match360kp.onPlayerOver userId=', event.userId, 'matchId=',
                   event.matchId, 'signinParams=', event.player.signinParams,
                   'snsId=', event.player.snsId, 'conf=', conf, 'result=',
                   result)


def _initialize():
    pkeventbus.globalEventBus.subscribe(MatchPlayerSigninEvent,
                                        _onPlayerSignin)
    pkeventbus.globalEventBus.subscribe(MatchPlayerOverEvent, _onPlayerOver)


if __name__ == '__main__':
    print signin(
        'REGIST', {
            'uid': '398710402',
            'gkey': 'vdhscvnmqvf',
            'skey': 1,
            'time': 1446195106,
            'matchid': '6043'
        })
    print strutil.md5digest('%s%s' % ('vdhscvnmqvf', 'REGIST'))
Example #13
0
    })
    params['result'] = matchResult

    result = webpage.webgetJson(callbackUrl, datas=params, appKey=None, timeout=conf.get('timeout', 3))
    if ftlog.is_debug():
        ftlog.debug('match360kp.onPlayerOver userId=', event.userId,
                    'matchId=', event.matchId,
                    'signinParams=', event.player.signinParams,
                    'snsId=', event.player.snsId,
                    'conf=', conf,
                    'result=', result)

    if not result or 'errno' in result:
        ftlog.warn('match360kp.onPlayerOver userId=', event.userId,
                   'matchId=', event.matchId,
                   'signinParams=', event.player.signinParams,
                   'snsId=', event.player.snsId,
                   'conf=', conf,
                   'result=', result)


def _initialize():
    pkeventbus.globalEventBus.subscribe(MatchPlayerSigninEvent, _onPlayerSignin)
    pkeventbus.globalEventBus.subscribe(MatchPlayerOverEvent, _onPlayerOver)


if __name__ == '__main__':
    print signin('REGIST',
                 {'uid': '398710402', 'gkey': 'vdhscvnmqvf', 'skey': 1, 'time': 1446195106, 'matchid': '6043'})
    print strutil.md5digest('%s%s' % ('vdhscvnmqvf', 'REGIST'))
Example #14
0
def _sign(params):
    sk = sorted(params.keys())
    strs = ['%s=%s' % (k, str(params[k])) for k in sk]
    md5str = 'market.tuyoo.com-api-%s-market.tuyoo-api' % (''.join(strs))
    return strutil.md5digest(md5str)
Example #15
0
 def sendAllRecordToUser(cls, userId, gameId):
     """全量下发
     """
     gameDataKey = cls._getUserRecordKey(userId, gameId)
     replayDBKey = 'replay:%s' % (gameId)
     if daobase.executeUserCmd(userId, 'HEXISTS', gameDataKey, 'game_record'):
         gameRecord = daobase.executeUserCmd(userId, 'HGET', gameDataKey, 'game_record')
         ftlog.debug("sendAllRecordToUser.gameRecord = ", gameRecord)
         recordData = json.loads(gameRecord)
         if len(recordData['recordIndex']) > 0:
             records = []
             for temp in recordData['recordIndex']:
                 record = daobase.executeRePlayCmd('HGET', replayDBKey, temp)
                 if record:
                     records.append(record)
             ftlog.debug("sendAllRecordToUser.records = ", records)
             if isinstance(records, list) and len(records) > 0:
                 msg = MsgPack()
                 msg.setCmd('create_table')
                 msg.setResult('action', 'record')
                 msg.setResult('type', 'update')
                 msg.setResult('gameId', gameId)
                 retList = []
                 for recordStr in records:
                     if not recordStr:
                         continue
                     try:
                         ftlog.debug("sendAllRecordToUsersetRetData1")
                         record = json.loads(recordStr)
                         defaultScore = record.get('defaultScore', 0)
                         urls = record.get('recordUrls', [])
                         retData = {}
                         retData['recordTime'] = record.get('time', 0)
                         retData['createTableNo'] = record['tableNo']
                         # 客户端牌局回放key
                         retData['tableRecordKey'] = '%s.%s' % (
                         record.get('createTime', 0), retData['createTableNo'])
                         retData['record_download_info'] = []
                         retData['users'] = []
                         ftlog.debug("sendAllRecordToUsersetRetData2")
                         for uid, info in record['budget'].items():
                             deltaScoreList = info.get('deltaScoreList', 0)
                             score = info.get('score', [])
                             if isinstance(score, int):
                                 score = []
                             retData['users'].append({'name': info['name'], 'score': score, 'userId': info['uid'],
                                                      'deltaScore': deltaScoreList})
                             # 胜负结果字段
                             if int(uid) == userId:
                                 if deltaScoreList > 0:
                                     retData['winScore'] = 1
                                 elif deltaScoreList == 0:
                                     retData['winScore'] = 0
                                 elif deltaScoreList < 0:
                                     retData['winScore'] = -1
                                 else:
                                     retData['winScore'] = 0
                             if int(uid) == userId:
                                 retData['deltaScore'] = 0 - defaultScore
                                 for i in range(len(urls)):
                                     record_download_info_obj = {}
                                     record_download_info_obj['url'] = '%s' % (urls[i])
                                     record_download_info_obj['fileType'] = ''
                                     record_download_info_obj['MD5'] = md5digest(
                                         record_download_info_obj['url']).upper()
                                     retData['record_download_info'].append(record_download_info_obj)
                         ftlog.debug("sendAllRecordToUsersetRetData3", retData)
                         retList.append(retData)
                     except:
                         ftlog.error('==sendAllRecordToUser ===', records, ' keys:', recordData['recordIndex'])
                 msg.setResult('list', retList)
                 router.sendToUser(msg, userId)
     else:
         return
Example #16
0
def _sign(params):
    sk = sorted(params.keys())
    strs = ['%s=%s' % (k, str(params[k]).strip()) for k in sk]
    md5str = strutil.tyDesEncode('&'.join(strs))
    return strutil.md5digest(md5str)
Example #17
0
    def _doLogin(self):
        loginur = gdata.httpSdkInner() + '/open/v3/user/processSnsId'
        params = {
            'svninfo':
            '$robot$',
            'appId':
            str(self.gameId),
            'ty_bindmobile':
            '',
            'phoneType':
            '',
            'imei':
            ['Xb6tiNAVcw5eLrd1F4JTW2dnDrGNr3P0EXl2x99NUeVYGHCQB6ECeQ=='],
            'iccid': [
                'RcjQJPkcLGfazgYaKJGWd8hTMfWp8OVr86NEoHuo1C0fIaCKUsTAhuB7huInoqWf'
            ],
            'androidId': [
                'BwyJv/PH1UCPjZDob4BSPgiwpuTq4dYgt1OFMrAoLJTED4oxlxdnEtuXKiOJxpkV'
            ],
            'snsToken':
            '',
            'mac': [
                'wn+rGmlh6/AG6S6O+7kew0ZaMHsfR0LstUtr/WOvXtX681nrM5c+406L0PvY3P7W'
            ],
            'ty_uid':
            '0',
            'clientId':
            self.clientId,
            'deviceName':
            self.name,
            'snsId':
            strutil.tyDesEncode(self.snsId),
            'deviceId':
            ''
        }
        sigstr = ''
        pkeys = params.keys()
        pkeys.sort()
        for k in pkeys:
            sigstr = sigstr + str(k) + '=' + str(params[k]) + '&'
        sigstr = sigstr[:-1]
        code = strutil.md5digest(strutil.tyDesEncode(sigstr))
        params['code'] = code

        userInfo, _ = webpage.webget(loginur, params)
        userInfo = strutil.loads(userInfo,
                                 ignoreException=True,
                                 execptionValue=userInfo)
        if not isinstance(userInfo, dict):
            ftlog.warn('snsId=', self.snsId, 'login-> return error !',
                       userInfo)
            self.stop()
            return
        if self.isbusy == 0:  # 已经关闭
            return

        ftlog.debug('snsId=', self.snsId, 'login->', userInfo)

        result = userInfo.get('result', {})
        self.userId = result.get('userId', 0)
        if not isinstance(self.userId, int) or self.userId < 0:
            raise Exception('robot user login false !' + self.snsId)
        ftlog.debug('Robot login ok snsId=', self.snsId, 'userId=',
                    self.userId)
        self.userInfo = result
        self.checkState(CMD_LOGIN)
Example #18
0
 def _buildSign(cls, path, body, stampstr, secret):
     params_joined = path + body + stampstr + secret
     return strutil.md5digest(params_joined.encode('utf-8')).upper()
Example #19
0
 def _sign(cls, params):
     sk = sorted(params.keys())
     strs = ['%s=%s' % (k, params[k]) for k in sk]
     md5str = strutil.tyDesEncode('&'.join(strs))
     return strutil.md5digest(md5str)
Example #20
0
def signin(action, params):
    gkey = params.get('gkey')
    key = strutil.md5digest('%s%s' % (gkey, action))
    sstr = '%s%s%s%s%s#%s' % (params.get('uid'), gkey, params.get('skey'),
                              params.get('time'), params.get('matchid'), key)
    return strutil.md5digest(sstr)
Example #21
0
def webget(httpurl, querys={}, appKey=None, postdata_='',
           method_='POST', headers_={}, cookies={},
           connect_timeout=3, timeout=3, needresponse=True,
           codeKey='code', appKeyTail=None, filterParams=[], connector="&"):
    '''
    调用远程HTTP接口, 并返回JSON结果
    '''
    params = []
    if isinstance(querys, (list, tuple)):
        params.extend(querys)
    elif isinstance(querys, dict):
        keys = querys.keys()
        keys.sort()
        for k in keys:
            params.append(k)
            params.append(querys[k])

    for x in xrange(len(params)):
        param = params[x]
        if isinstance(param, unicode):
            param = param.encode('utf8')
        else:
            param = str(param)
        params[x] = param

    query2 = []
    query = []
    for x in xrange(len(params) / 2):
        k = params[x * 2]
        v = params[x * 2 + 1]
        if k not in filterParams:
            query.append(k + '=' + v)
        if k == 'authInfo':  # TODO 这部分代码是最老版的第三方的支持
            query2.append(k + '=' + v)
        else:
            query2.append(k + '=' + urllib.quote(v))
    query = connector.join(query)
    query2 = '&'.join(query2)
    if appKey:
        if appKeyTail:
            md5str = str(appKey) + query + str(appKeyTail)
        else:
            md5str = str(appKey) + query + str(appKey)
        ftlog.debug("webgetGdss,md5str:", md5str)
        md5code = strutil.md5digest(md5str)
        query2 = query2 + '&' + codeKey + '=' + md5code

    if isinstance(httpurl, unicode):
        httpurl = httpurl.encode('utf8')

    if len(query2) > 0:
        if httpurl.find('?') > 0:
            httpurl = httpurl + '&' + query2
        else:
            httpurl = httpurl + '?' + query2

    if isinstance(httpurl, unicode):
        httpurl = httpurl.encode('utf8')

    if postdata_ and isinstance(postdata_, dict):
        postdata_ = urllib.urlencode(postdata_)

    if headers_ == None or len(headers_) == 0:
        headers_ = {'Content-type': ['application/x-www-form-urlencoded']}

    if needresponse:
        _, hbody = http.runHttp(method=method_, url=httpurl, header=headers_, body=postdata_,
                                connect_timeout=connect_timeout, timeout=timeout)
        return hbody, httpurl
    else:
        http.runHttpNoResponse(method_, httpurl, headers_, postdata_, connect_timeout)
        return None, httpurl
Example #22
0
 def __init__(self):
     self.sn = 'SDK-BBX-010-19139'
     pwd = '140408'
     pwd = strutil.md5digest(self.sn + pwd)
     self.pwd = pwd.upper()
     self.smsurl = u'http://sdk2.entinfo.cn:8061/mdsmssend.ashx?'
Example #23
0
def genSigninCode(params):
    sk = sorted(params.keys())
    strs = ['%s=%s' % (k, str(params[k]).strip()) for k in sk]
    cstr = '&'.join(strs)
    cstr += API_KEY
    return strutil.md5digest(cstr)
def sendAllRecordToUser(cls, userId, gameId):
    """全量下发
    """
    gameDataKey = cls._getUserRecordKey(userId, gameId)
    replayDBKey = 'replay:%s' % (gameId)
    if daobase.executeUserCmd(userId, 'HEXISTS', gameDataKey, 'game_record'):
        gameRecord = daobase.executeUserCmd(userId, 'HGET', gameDataKey,
                                            'game_record')
        ftlog.debug("sendAllRecordToUser.gameRecord = ", gameRecord)
        recordData = json.loads(gameRecord)
        if len(recordData['recordIndex']) > 0:
            records = []
            for temp in recordData['recordIndex']:
                record = daobase.executeRePlayCmd('HGET', replayDBKey, temp)
                if record:
                    records.append(record)
            ftlog.debug("sendAllRecordToUser.records = ", records)
            if isinstance(records, list) and len(records) > 0:
                msg = MsgPack()
                msg.setCmd('create_table')
                msg.setResult('action', 'record')
                msg.setResult('type', 'update')
                msg.setResult('gameId', gameId)
                retList = []
                for recordStr in records:
                    if not recordStr:
                        continue
                    try:
                        ftlog.debug("sendAllRecordToUsersetRetData1")
                        record = json.loads(recordStr)
                        defaultScore = record.get('defaultScore', 0)
                        urls = record.get('recordUrls', [])
                        retData = {}
                        retData['recordTime'] = record.get('time', 0)
                        retData['createTableNo'] = record['tableNo']
                        # 客户端牌局回放key
                        retData['tableRecordKey'] = '%s.%s' % (record.get(
                            'createTime', 0), retData['createTableNo'])
                        retData['record_download_info'] = []
                        retData['users'] = []
                        ftlog.debug("sendAllRecordToUsersetRetData2")
                        for uid, info in record['budget'].items():
                            deltaScoreList = info.get('deltaScoreList', 0)
                            score = info.get('score', [])
                            if isinstance(score, int):
                                score = []
                            retData['users'].append({
                                'name':
                                info['name'],
                                'score':
                                score,
                                'userId':
                                info['uid'],
                                'deltaScore':
                                deltaScoreList
                            })
                            # 胜负结果字段
                            if int(uid) == userId:
                                if deltaScoreList > 0:
                                    retData['winScore'] = 1
                                elif deltaScoreList == 0:
                                    retData['winScore'] = 0
                                elif deltaScoreList < 0:
                                    retData['winScore'] = -1
                                else:
                                    retData['winScore'] = 0
                            if int(uid) == userId:
                                retData['deltaScore'] = 0 - defaultScore
                                for i in range(len(urls)):
                                    record_download_info_obj = {}
                                    record_download_info_obj['url'] = '%s' % (
                                        urls[i])
                                    record_download_info_obj['fileType'] = ''
                                    record_download_info_obj[
                                        'MD5'] = md5digest(
                                            record_download_info_obj['url']
                                        ).upper()
                                    retData['record_download_info'].append(
                                        record_download_info_obj)
                        ftlog.debug("sendAllRecordToUsersetRetData3", retData)
                        retList.append(retData)
                    except:
                        ftlog.error('==sendAllRecordToUser ===', records,
                                    ' keys:', recordData['recordIndex'])
                msg.setResult('list', retList)
                router.sendToUser(msg, userId)
    else:
        return
Example #25
0
def webget(httpurl,
           querys={},
           appKey=None,
           postdata_='',
           method_='POST',
           headers_={},
           cookies={},
           connect_timeout=3,
           timeout=3,
           needresponse=True,
           codeKey='code',
           appKeyTail=None,
           filterParams=[],
           connector="&"):
    '''
    调用远程HTTP接口, 并返回JSON结果
    '''
    params = []
    if isinstance(querys, (list, tuple)):
        params.extend(querys)
    elif isinstance(querys, dict):
        keys = querys.keys()
        keys.sort()
        for k in keys:
            params.append(k)
            params.append(querys[k])

    for x in xrange(len(params)):
        param = params[x]
        if isinstance(param, unicode):
            param = param.encode('utf8')
        else:
            param = str(param)
        params[x] = param

    query2 = []
    query = []
    for x in xrange(len(params) / 2):
        k = params[x * 2]
        v = params[x * 2 + 1]
        if k not in filterParams:
            query.append(k + '=' + v)
        if k == 'authInfo':  # TODO 这部分代码是最老版的第三方的支持
            query2.append(k + '=' + v)
        else:
            query2.append(k + '=' + urllib.quote(v))
    query = connector.join(query)
    query2 = '&'.join(query2)
    if appKey:
        if appKeyTail:
            md5str = str(appKey) + query + str(appKeyTail)
        else:
            md5str = str(appKey) + query + str(appKey)
        ftlog.debug("webgetGdss,md5str:", md5str)
        md5code = strutil.md5digest(md5str)
        query2 = query2 + '&' + codeKey + '=' + md5code

    if isinstance(httpurl, unicode):
        httpurl = httpurl.encode('utf8')

    if len(query2) > 0:
        if httpurl.find('?') > 0:
            httpurl = httpurl + '&' + query2
        else:
            httpurl = httpurl + '?' + query2

    if isinstance(httpurl, unicode):
        httpurl = httpurl.encode('utf8')

    if postdata_ and isinstance(postdata_, dict):
        postdata_ = urllib.urlencode(postdata_)

    if headers_ == None or len(headers_) == 0:
        headers_ = {'Content-type': ['application/x-www-form-urlencoded']}

    if needresponse:
        _, hbody = http.runHttp(method=method_,
                                url=httpurl,
                                header=headers_,
                                body=postdata_,
                                connect_timeout=connect_timeout,
                                timeout=timeout)
        return hbody, httpurl
    else:
        http.runHttpNoResponse(method_, httpurl, headers_, postdata_,
                               connect_timeout)
        return None, httpurl