Beispiel #1
0
def custom_send(access_token, data, **kwargs):
    """ 发送客服消息 """
    api = 'https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={}'.format(
        access_token)
    data.update(**kwargs)

    return requests_post(api, data)
Beispiel #2
0
def getwxacode(access_token, path, **kwargs):
    """ 接口A: 适用于需要的码数量较少的业务场景 """
    api = 'https://api.weixin.qq.com/wxa/getwxacode?access_token={}'.format(access_token)
    data = {'path': path}
    data.update(**kwargs)

    return requests_post(api, data)
Beispiel #3
0
def createwxaqrcode(access_token, path, **kwargs):
    """ 接口C:适用于需要的码数量较少的业务场景 """
    api = 'https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token={}'.format(access_token)
    data = {'path': path}
    data.update(**kwargs)

    return requests_post(api, data)
Beispiel #4
0
def getwxacodeunlimit(access_token, scene, **kwargs):
    """ 接口B:适用于需要的码数量极多的业务场景 """
    api = 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token={}'.format(access_token)
    data = {'scene': scene}
    data.update(**kwargs)

    return requests_post(api, data)
Beispiel #5
0
def library_list(access_token, offset, count, **kwargs):
    """ 获取小程序模板库标题列表 """
    api = 'https://api.weixin.qq.com/cgi-bin/wxopen/template/library/list?access_token={}'.format(
        access_token)
    data = {'offset': offset, 'count': count}
    data.update(**kwargs)

    return requests_post(api, data)
Beispiel #6
0
def send(access_token, touser, template_id, **kwargs):
    """ 发送模板消息 """
    api = 'https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token={}'.format(
        access_token)
    data = {'touser': touser, 'template_id': template_id}
    data.update(**kwargs)

    return requests_post(api, data)
Beispiel #7
0
def delete(access_token, template_id, **kwargs):
    """ 删除帐号下的某个模板 """
    api = 'https://api.weixin.qq.com/cgi-bin/wxopen/template/del?access_token={}'.format(
        access_token)
    data = {'template_id': template_id}
    data.update(**kwargs)

    return requests_post(api, data)
Beispiel #8
0
def add(access_token, title_id, keyword_id_list, **kwargs):
    """ 组合模板并添加至帐号下的个人模板库 """
    api = 'https://api.weixin.qq.com/cgi-bin/wxopen/template/add?access_token={}'.format(
        access_token)
    data = {'id': title_id, 'keyword_id_list': keyword_id_list}
    data.update(**kwargs)

    return requests_post(api, data)
Beispiel #9
0
def library_get(access_token, title_id, **kwargs):
    """ 获取模板库某个模板标题下关键词库 """
    api = 'https://api.weixin.qq.com/cgi-bin/wxopen/template/library/get?access_token={}'.format(
        access_token)
    data = {'id': title_id}
    data.update(**kwargs)

    return requests_post(api, data)
Beispiel #10
0
    def getbalance(self, access_token, session_key, open_id, **kwargs):
        """
        查询余额: 查看某个用户的游戏币余额
        """
        path = '/cgi-bin/midas/sandbox/getbalance' if self.sandbox else '/cgi-bin/midas/getbalance'
        api = 'https://api.weixin.qq.com{}?access_token={}'.format(
            path, access_token)
        params = {'openid': open_id}
        data = self.build_params(access_token, session_key, params, path,
                                 **kwargs)

        return requests_post(api, data)
Beispiel #11
0
def wxopen_updatablemsg_send(access_token, activity_id, target_state,
                             template_info, **kwargs):
    """ 发送客服消息 """
    api = 'https://api.weixin.qq.com/cgi-bin/message/wxopen/updatablemsg/send?access_token={}'.format(
        access_token)
    data = {
        'activity_id': activity_id,
        'target_state': target_state,
        'template_info': template_info,
    }
    data.update(**kwargs)

    return requests_post(api, data)
Beispiel #12
0
    def cancelpay(self, access_token, session_key, open_id, bill_no, **kwargs):
        """
        取消支付: 在有效期内的订单,可以通过本接口取消该笔扣除游戏币的订单
        """
        path = '/cgi-bin/midas/sandbox/cancelpay' if self.sandbox else '/cgi-bin/midas/cancelpay'
        api = 'https://api.weixin.qq.com{}?access_token={}'.format(
            path, access_token)
        params = {
            'openid': open_id,
            'bill_no': bill_no,
        }
        data = self.build_params(access_token, session_key, params, path,
                                 **kwargs)

        return requests_post(api, data)
Beispiel #13
0
    def pay(self, access_token, session_key, open_id, bill_no, amount,
            **kwargs):
        """
        扣除游戏币: 扣除某个用户的游戏币
        """
        path = '/cgi-bin/midas/sandbox/pay' if self.sandbox else '/cgi-bin/midas/pay'
        api = 'https://api.weixin.qq.com{}?access_token={}'.format(
            path, access_token)
        params = {
            'openid': open_id,
            'amt': amount,
            'bill_no': bill_no,
        }
        data = self.build_params(access_token, session_key, params, path,
                                 **kwargs)

        return requests_post(api, data)
Beispiel #14
0
    def present(self, access_token, session_key, open_id, bill_no,
                present_counts, **kwargs):
        """
        游戏币赠送: 向某个用户赠送游戏币
        """
        path = '/cgi-bin/midas/sandbox/present' if self.sandbox else '/cgi-bin/midas/present'
        api = 'https://api.weixin.qq.com{}?access_token={}'.format(
            path, access_token)
        params = {
            'openid': open_id,
            'bill_no': bill_no,
            'present_counts': present_counts,
        }
        data = self.build_params(access_token, session_key, params, path,
                                 **kwargs)

        return requests_post(api, data)