Ejemplo n.º 1
0
    def __init__(self, appid, appkey, iplist):
        super(OpenAPIV3, self).__init__()
        self._appid = appid
        self._appkey = appkey

        secret = '%s&' % self._appkey
        self._api = SNSNetwork(secret, iplist)
        self._statapi = SnsStat()
Ejemplo n.º 2
0
class OpenAPIV3(object):
    _appid = 0
    _appkey = ''
    _api = None
    _staturl = "apistat.tencentyun.com"
    _statapi = None
    _is_stat = True

    def __init__(self, appid, appkey, iplist):
        super(OpenAPIV3, self).__init__()
        self._appid = appid
        self._appkey = appkey

        secret = '%s&' % self._appkey
        self._api = SNSNetwork(secret, iplist)
        self._statapi = SnsStat()

    def call(self, url_path, params, method='post', protocol='http'):
        '''
        调用接口,并将数据格式转化成json
        只需要传入pf, openid, openkey等参数即可,不需要传入sig
        format即使传xml也没有用,会被强制改为json
        '''
        cp_params = copy.deepcopy(params)
        cp_params.update({'appid': self._appid, 'format': 'json'})

        stat_startime = self._statapi.getTime()
        try:
            data = self._api.open(method, url_path, cp_params, protocol)
        except Exception, e:
            msg = 'exception occur.msg[%s], traceback[%s]' % (
                str(e), __import__('traceback').format_exc())
            return {'ret': OPEN_HTTP_TRANSLATE_ERROR, 'msg': msg}
        else:
Ejemplo n.º 3
0
    def __init__(self, appid, appkey, iplist):
        super(OpenAPIV3, self).__init__()
        self._appid = appid
        self._appkey = appkey

        secret = '%s&' % self._appkey
        self._api = SNSNetwork(secret, iplist)
        self._statapi = SnsStat()
Ejemplo n.º 4
0
class OpenAPIV3(object):
    _appid = 0
    _appkey = ''
    _api = None
    _staturl = "apistat.tencentyun.com"
    _statapi = None
    _is_stat = True

    def __init__(self, appid, appkey, iplist):
        super(OpenAPIV3, self).__init__()
        self._appid = appid
        self._appkey = appkey

        secret = '%s&' % self._appkey
        self._api = SNSNetwork(secret, iplist)
        self._statapi = SnsStat()

    def call(self, url_path, params, method='post', protocol='http'):
        '''
        调用接口,并将数据格式转化成json
        只需要传入pf, openid, openkey等参数即可,不需要传入sig
        format即使传xml也没有用,会被强制改为json
        '''
        cp_params = copy.deepcopy(params)
        cp_params.update(
            {
                'appid': self._appid,
                'format': 'json'
            }
            )

        stat_startime = self._statapi.getTime()
        data = None
        try:
            data = self._api.open(method, url_path, cp_params, protocol)
        except Exception, e:
            msg = 'exception occur.msg[%s], traceback[%s]' % (str(e), __import__('traceback').format_exc())
            return {'ret':OPEN_HTTP_TRANSLATE_ERROR, 'msg':msg}
        else: