Skip to content

Instantly share code, notes, and snippets.

@alairock
Created June 13, 2018 22:48
Show Gist options
  • Save alairock/c340a7ab7216a5bf729b7b8f2458e547 to your computer and use it in GitHub Desktop.
Save alairock/c340a7ab7216a5bf729b7b8f2458e547 to your computer and use it in GitHub Desktop.
headers = {
"Rest-Impersonate-User": userid,
"Rest-User-Token": "XXXXXXXXXXXXXXXXXXXXXXX",
}
try:
json = {
'ThreadId': thread_id,
'ForumId': 21,
'Body': data['raw'],
'PostDate': data['created_at'].strftime("%Y-%m-%d %H:%M:%S")
}
post(f"{base_url}/api.ashx/v2/forums/21/threads/{thread_id}/replies.json", json=json, headers=headers) as resp:
if resp.status != 200:
print('post status', resp.text)
else:
print('success')
return resp
headers = {
"Rest-Impersonate-User": userid,
"Rest-User-Token": "XXXXXXXXXXXXXXXXXXXXXXX",
}
try:
json = {
'ForumId': 21,
'Subject': data['title'],
'Body': data['raw'],
'PostDate': data['created_at'].strftime("%Y-%m-%d %H:%M:%S")
}
post(f"{base_url}/api.ashx/v2/forums/21/threads.json", json=json, headers=headers) as resp:
if resp.status != 200:
print('post status', resp.text)
else:
print('success')
return resp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment