Ejemplo n.º 1
0
def post_status(
    app,
    user,
    status,
    visibility='public',
    media_ids=None,
    sensitive=False,
    spoiler_text=None,
    in_reply_to_id=None,
    language=None,
):
    """
    Posts a new status.
    https://github.com/tootsuite/documentation/blob/master/Using-the-API/API.md#posting-a-new-status
    """

    # Idempotency key assures the same status is not posted multiple times
    # if the request is retried.
    headers = {"Idempotency-Key": uuid.uuid4().hex}

    return http.post(app,
                     user,
                     '/api/v1/statuses', {
                         'status': status,
                         'media_ids[]': media_ids,
                         'visibility': visibility,
                         'sensitive': str_bool(sensitive),
                         'spoiler_text': spoiler_text,
                         'in_reply_to_id': in_reply_to_id,
                         'language': language,
                     },
                     headers=headers).json()
Ejemplo n.º 2
0
def tag_timeline_generator(instance, hashtag, local=False, limit=20):
    path = '/api/v1/timelines/tag/{}'.format(hashtag)
    params = {'local': str_bool(local), 'limit': limit}
    return _anon_timeline_generator(instance, path, params)
Ejemplo n.º 3
0
def public_timeline_generator(instance, local=False, limit=20):
    path = '/api/v1/timelines/public'
    params = {'local': str_bool(local), 'limit': limit}
    return _anon_timeline_generator(instance, path, params)
Ejemplo n.º 4
0
def tag_timeline_generator(app, user, hashtag, local=False, limit=20):
    path = '/api/v1/timelines/tag/{}'.format(quote(hashtag))
    params = {'local': str_bool(local), 'limit': limit}
    return _timeline_generator(app, user, path, params)
Ejemplo n.º 5
0
def timeline_tag(app, user, hashtag, local=False):
    url = '/api/v1/timelines/tag/{}'.format(quote(hashtag))
    params = {'local': str_bool(local)}
    return http.get(app, user, url, params).json()
Ejemplo n.º 6
0
def timeline_public(app, user, local=False):
    params = {'local': str_bool(local)}
    return http.get(app, user, '/api/v1/timelines/public', params).json()