Esempio n. 1
0
def add_post(author_id, nickname, avatar, parent_id, group_name, content, pictures):
    magic_number = "???CIWEI-CO[.]"
    timestamp = str(now())
    token = hashlib.md5(timestamp + magic_number).hexdigest()
    url = DSE_SERVICE_POST_URL
    headers = {
        'content-type': 'application/json',
    }
    data = {
        "privateToken": token,
        "timestamp": timestamp,
        "content": {
            "parentId": parent_id,
            "groupName": group_name,
            "content": content,
            "pictures": pictures.split(','),
            "authorId": author_id,
            "nickname": nickname,
            "avatar": avatar,
            "type": 0,
        },
    }

    req = requests.post(url, headers=headers, json=data)
    print req.content
    return req.json()
Esempio n. 2
0
 def min_url_for(endpoint, **values):
     if endpoint == 'static':
         filename = values.get('filename', None)
         if filename and 'common' in filename and not app.debug:
             root, ext = os.path.splitext(filename)
             if ext and ext in ['.js', '.css'] and '.min' not in root:
                 new_ext = ".min" + ext
                 values['filename'] = root + new_ext
         # 调试模式下为每个请求添加一个参数避免缓存影响js调试
         elif filename and app.debug:
             values['cached'] = utils.now()
     return url_for(endpoint, **values)
Esempio n. 3
0
def get_groups_by_rule(group_rule):
    magic_number = "???CIWEI-CO[.]"
    timestamp = str(now())
    token = hashlib.md5(timestamp + magic_number + group_rule).hexdigest()
    url = DSE_SERVICE_ALL_GROUP_URL
    headers = {
        'content-type': 'application/json',
    }
    data = {
        "privateToken": token,
        "timestamp": timestamp,
        "rule": group_rule,
    }

    req = requests.get(url, headers=headers, json=data, verify=True)
    res = req.json()
    return res