Exemplo n.º 1
0
def delete(path, data):
    if data is None:
        return requests.delete(config.get_url(path),
                               headers=auth.get_headers(
                                   config.api_key, config.api_secret))
    else:
        return requests.delete(config.get_url(path),
                               headers=auth.get_headers(
                                   config.api_key, config.api_secret),
                               json=data)
Exemplo n.º 2
0
def upload_image(path):
    with open(path, "rb") as image_file:
        encoded_string = base64.b64encode(image_file.read())
    data = {'file': str(encoded_string)[2:-1], 'type': 'MMS'}
    headers = auth.get_headers(config.api_key, config.api_secret)
    return requests.post(config.get_url('/storage/v1/files'),
                         headers=headers,
                         json=data)
Exemplo n.º 3
0
import requests
import json
from src.lib import config, auth
'''
모든 메시지를 조회하는 예제
'''
if __name__ == '__main__':
    res = requests.get(config.get_url('/messages/v4/list'),
                       headers=auth.get_headers(config.api_key,
                                                config.api_secret))
    print(json.dumps(res.json(), indent=2, ensure_ascii=False))

    # limit
    res = requests.get(config.get_url('/messages/v4/list?limit=10'),
                       headers=auth.get_headers(config.api_key,
                                                config.api_secret))
    print(json.dumps(res.json(), indent=2, ensure_ascii=False))

    # messageId
    res = requests.get(config.get_url('/messages/v4/list?messageId=XXXXXXX'),
                       headers=auth.get_headers(config.api_key,
                                                config.api_secret))
    print(json.dumps(res.json(), indent=2, ensure_ascii=False))

    # groupId
    res = requests.get(config.get_url('/messages/v4/list?groupId=XXXXXXX'),
                       headers=auth.get_headers(config.api_key,
                                                config.api_secret))
    print(json.dumps(res.json(), indent=2, ensure_ascii=False))

    # 수신번호로 조회
Exemplo n.º 4
0
def get(path, headers=None):
    if headers is None:
        headers = {}
    headers.update(auth.get_headers(config.api_key, config.api_secret))
    return requests.get(config.get_url(path), headers=headers)
Exemplo n.º 5
0
def post(path, data):
    return requests.post(config.get_url(path),
                         headers=auth.get_headers(config.api_key,
                                                  config.api_secret),
                         json=data)
Exemplo n.º 6
0
def send_one(data):
    data['agent'] = default_agent
    return requests.post(config.get_url('/messages/v4/send'),
                         headers=auth.get_headers(config.api_key,
                                                  config.api_secret),
                         json=data)