コード例 #1
0
    def POST(self):
        try:
            tid_value = web.input()['tid']
        except KeyError:
            return web.BadRequest()

        try:
            team_id = cfg['TEAM_ID_DICT'][tid_value.upper()]
        except KeyError:
            return web.Unauthorized()

        if len(web.data()) == 0:
            return web.BadRequest()

        data = simplejson.loads(web.data())
        # json validation
        good, errors = IssueValidator().validate(data)
        if not good:
            return errors

        r = requests.post(''.join(['http://', cfg['REMOTE_HOST'], '/pp']), data=simplejson.dumps({'tid': str(team_id), 'iid': data['ID']}))
        if r.status_code != 200:
            print 'Call remote server failed...'
            print r.text

        api = WxApi(cfg['CORP_ID'], cfg['SECRET'])
        api.send_text(self.build_msg(data), team_id, 0, '@all')

        return web.OK('ok')
コード例 #2
0
    def POST(self):
        try:
            tid_value = web.input()['tid']
        except KeyError:
            return web.BadRequest()

        try:
            team_id = cfg['TEAM_ID_DICT'][tid_value.upper()]
        except KeyError:
            return web.Unauthorized()

        if len(web.data()) == 0:
            return web.BadRequest()

        api = WxApi(cfg['CORP_ID'], cfg['SECRET'])
        api.send_text(web.data(), team_id, 0, '@all')

        return web.OK('ok')
コード例 #3
0
def send_to_all(req, msg):
    api = WxApi(cfg["CORP_ID"], cfg["SECRET"])
    api.send_text(msg, req.AgentID, "0", "@all")
    return WxEmptyResponse()
コード例 #4
0
def send_to_all(req, msg):
    api = WxApi(cfg['CORP_ID'], cfg['SECRET'])
    api.send_text(msg, req.AgentID, '0', '@all')
    return WxEmptyResponse()