XF 2.1 editing posts via python

lashman

Active member
well, i don't think i can manage to get any further than i already have on my own, so i have to ask

how exactly would i go about editing posts via python calls? i wrote a script that lets me post new messages into a specified thread, but i would like to also figure out how to edit messages if i'm posting a new one within a certain time.

here's what i've got:

Python:
    if datetime.strptime(datetime.now().strftime('%Y-%m-%d %H:%M:%S'), '%Y-%m-%d %H:%M:%S') - last_post_date <= timedelta(minutes = 60):
        data = {
            'thread_id': thread_id,
            'post_id': last_post_data['last_post_id'],
            'message': forumPost
        }
        r = requests.post(url, headers = headers, data = data)
        print("edited post")
    else:
        data = {
            'thread_id': thread_id,
            'message': forumPost
        }
        print("regular post")
        r = requests.post(url, headers = headers, data = data)

obviously - both bits of code just post a new message right now, but i would like the first one to edit the specified message instead

help, please! 😔
 
As an entry point: Use the "xenForo API" and only work with that. Fetch the post_id, make an edit request for that post_id using the xenForo API. That is very simple.
 
Back
Top Bottom