Skip to content

Instantly share code, notes, and snippets.

@fhocutt

fhocutt/flowapiresult Secret

Last active Aug 29, 2015
Embed
What would you like to do?
action=flow&submodule=new-topic API result
Method that uses mwclient's Site.api method to post a new topic to a Flow board:
def postflow(page, topic, message, site):
"""testing posting a new Flow topic through the API"""
token = site.get_token('csrf')
cooptitle = 'Wikipedia:Co-op/Mentorship match'
kwargs = {'action': 'flow',
'page': cooptitle,
'submodule': 'new-topic',
'token': token,
'nttopic': topic,
'ntcontent': message,
'workflow': 's7hjfbzj7bjwke99'}
query2 = site.api(**kwargs)
return query2
Calling this in the Python interpreter, as:
>>> flowpost2 = mbapi.postflow('page', 'test topic2', 'test message2', site)
>>> pprint.pprint(flowpost2)
yields:
{u'flow': {u'new-topic': {u'result': {u'topiclist': {u'actions': {u'newtopic': {u'title': u'Start a new topic',
u'url': u'/w/index.php?title=Wikipedia:Co-op/Mentorship_match&action=new-topic'}},
u'errors': [],
u'links': {u'board-sort': {u'newest': u'/w/index.php?title=Wikipedia:Co-op/Mentorship_match&topiclist_sortby=newest&topiclist_savesortby=',
u'updated': u'/w/index.php?title=Wikipedia:Co-op/Mentorship_match&topiclist_sortby=updated&topiclist_savesortby='},
u'newtopic': u'/w/index.php?title=Wikipedia:Co-op/Mentorship_match&action=new-topic',
u'pagination': []},
u'posts': {u's7hjfc3k6rz71qul': [u's7hjfc4ihhjghulp'],
u's7hjfc5wdfg7btil': [u's7hjfc5wdfg7btil'],
u's7xiyvpkn2y1s1t9': [u's7xiyvrngzt6106l'],
u's7xiyvswokeyuey5': [u's7xiyvswokeyuey5']},
u'revisions': {u's7hjfc4ihhjghulp': {u'actions': {u'edit': {u'title': u'Edit title',
u'url': u'/w/index.php?title=Topic:S7hjfc3k6rz71qul&action=edit-title&topic_revId=s7hjfc4ihhjghulp'},
u'hide': {u'title': u'Hide topic',
u'url': u'/w/index.php?title=Topic:S7hjfc3k6rz71qul&action=moderate-topic&topic_moderationState=hide'},
u'lock': {u'title': u'Lock topic',
u'url': u'/w/index.php?title=Topic:S7hjfc3k6rz71qul&action=lock-topic&flow_moderationState=lock'},
u'reply': {u'title': u'Reply',
u'url': u'/w/index.php?title=Topic:S7hjfc3k6rz71qul&action=reply&topic_postId=s7hjfc3k6rz71qul#flow-reply-s7hjfc3k6rz71qul'},
u'summarize': {u'title': u'Summarize',
u'url': u'/w/index.php?title=Topic:S7hjfc3k6rz71qul&action=edit-topic-summary'},
u'thank': {u'title': u'thank',
u'url': u'/wiki/Special:Thanks/Flow/s7hjfc3k6rz71qul'}},
u'author': {u'gender': u'unknown',
u'id': 26519,
u'links': {u'contribs': {u'exists': True,
u'title': u'Contributions/MatchBot',
u'url': u'/wiki/Special:Contributions/MatchBot'},
u'talk': {u'exists': False,
u'title': u'User talk:MatchBot',
u'url': u'/wiki/User_talk:MatchBot'},
u'userpage': {u'exists': True,
u'title': u'MatchBot',
u'url': u'/wiki/User:MatchBot'}},
u'name': u'MatchBot',
u'wiki': u'testwiki'},
u'changeType': u'new-post',
u'content': {u'content': u'Hello, [[User:Fhocutt|Fhocutt]]! Thank you for your interest in the Co-op. [[User:Fhocutt|Fhocutt]] has listed "Writing" in their mentorship profile. Leave them a message on their talk page and see if you want to work together!',
u'format': u'plaintext'},
u'creator': {u'gender': u'unknown',
u'id': 26519,
u'links': {u'contribs': {u'exists': True,
u'title': u'Contributions/MatchBot',
u'url': u'/wiki/Special:Contributions/MatchBot'},
u'talk': {u'exists': False,
u'title': u'User talk:MatchBot',
u'url': u'/wiki/User_talk:MatchBot'},
u'userpage': {u'exists': True,
u'title': u'MatchBot',
u'url': u'/wiki/User:MatchBot'}},
u'name': u'MatchBot',
u'wiki': u'testwiki'},
u'dateFormats': [],
u'isMaxThreadingDepth': False,
u'isModerated': False,
u'isOriginalContent': True,
u'isWatched': False,
u'lastEditId': None,
u'lastEditUser': {u'gender': u'unknown',
u'id': None,
u'links': [],
u'name': None,
u'wiki': None},
u'last_updated': 1417913218000,
u'last_updated_readable': u'00:46, 7 December 2014',
u'links': {u'post': {u'title': u'post',
u'url': u'/w/index.php?title=Topic:S7hjfc3k6rz71qul&topic_showPostId=s7hjfc3k6rz71qul#flow-post-s7hjfc3k6rz71qul'},
u'topic': {u'title': u'topic',
u'url': u'/wiki/Topic:S7hjfc3k6rz71qul'},
u'topic-history': {u'title': u'History',
u'url': u'/w/index.php?title=Topic:S7hjfc3k6rz71qul&action=history'},
u'topic-revision': {u'title': u'topic revision',
u'url': u'/w/index.php?title=Topic:S7hjfc3k6rz71qul&topic_revId=s7hjfc4ihhjghulp&action=single-view'},
u'unwatch-topic': {u'title': u'Unwatch',
u'url': u'/w/index.php?title=Topic:S7hjfc3k6rz71qul&action=unwatch'},
u'watch-topic': {u'title': u'Watch',
u'url': u'/w/index.php?title=Topic:S7hjfc3k6rz71qul&action=watch'}},
u'postId': u's7hjfc3k6rz71qul',
u'previousRevisionId': None,
u'properties': {u'topic-of-post': {u'plaintext': u'Hello, [[User:Fhocutt|Fhocutt]]! Thank you for your interest in the Co-op. [[User:Fhocutt|Fhocutt]] has listed "Writing" in their mentorship profile. Leave them a message on their talk page and see if you want to work together!'}},
u'replies': [u's7hjfc5wdfg7btil'],
u'replyToId': None,
u'reply_count': 1,
u'revisionId': u's7hjfc4ihhjghulp',
u'size': {u'new': 227,
u'old': 0},
u'timestamp': u'20141207004658',
u'watchable': True,
u'workflowId': u's7hjfc3k6rz71qul'},
u's7hjfc5wdfg7btil': {u'actions': {u'hide': {u'title': u'Hide',
u'url': u'/w/index.php?title=Topic:S7hjfc3k6rz71qul&action=moderate-post&topic_postId=s7hjfc5wdfg7btil&topic_moderationState=hide'},
u'reply': {u'title': u'Reply',
u'url': u'/w/index.php?title=Topic:S7hjfc3k6rz71qul&action=reply&topic_postId=s7hjfc5wdfg7btil#flow-post-s7hjfc5wdfg7btil'},
u'summarize': {u'title': u'Summarize',
u'url': u'/w/index.php?title=Topic:S7hjfc3k6rz71qul&action=edit-topic-summary'},
u'thank': {u'title': u'thank',
u'url': u'/wiki/Special:Thanks/Flow/s7hjfc5wdfg7btil'}},
u'author': {u'gender': u'unknown',
u'id': 26519,
u'links': {u'contribs': {u'exists': True,
u'title': u'Contributions/MatchBot',
u'url': u'/wiki/Special:Contributions/MatchBot'},
u'talk': {u'exists': False,
u'title': u'User talk:MatchBot',
u'url': u'/wiki/User_talk:MatchBot'},
u'userpage': {u'exists': True,
u'title': u'MatchBot',
u'url': u'/wiki/User:MatchBot'}},
u'name': u'MatchBot',
u'wiki': u'testwiki'},
u'changeType': u'reply',
u'content': {u'content': u'<p data-parsoid=\'{"dsr":[0,41,0,0]}\'>Welcome to the Co-op! Here is your match.</p>',
u'format': u'html'},
u'creator': {u'gender': u'unknown',
u'id': 26519,
u'links': {u'contribs': {u'exists': True,
u'title': u'Contributions/MatchBot',
u'url': u'/wiki/Special:Contributions/MatchBot'},
u'talk': {u'exists': False,
u'title': u'User talk:MatchBot',
u'url': u'/wiki/User_talk:MatchBot'},
u'userpage': {u'exists': True,
u'title': u'MatchBot',
u'url': u'/wiki/User:MatchBot'}},
u'name': u'MatchBot',
u'wiki': u'testwiki'},
u'dateFormats': [],
u'isMaxThreadingDepth': False,
u'isModerated': False,
u'isOriginalContent': True,
u'isWatched': False,
u'lastEditId': None,
u'lastEditUser': {u'gender': u'unknown',
u'id': None,
u'links': [],
u'name': None,
u'wiki': None},
u'links': {u'post': {u'title': u'post',
u'url': u'/w/index.php?title=Topic:S7hjfc3k6rz71qul&topic_showPostId=s7hjfc5wdfg7btil#flow-post-s7hjfc5wdfg7btil'},
u'post-revision': {u'title': u'post revision',
u'url': u'/w/index.php?title=Topic:S7hjfc3k6rz71qul&topic_postId=s7hjfc5wdfg7btil&topic_revId=s7hjfc5wdfg7btil&action=single-view'},
u'topic': {u'title': u'topic',
u'url': u'/wiki/Topic:S7hjfc3k6rz71qul'},
u'topic-history': {u'title': u'History',
u'url': u'/w/index.php?title=Topic:S7hjfc3k6rz71qul&action=history'},
u'unwatch-topic': {u'title': u'Unwatch',
u'url': u'/w/index.php?title=Topic:S7hjfc3k6rz71qul&action=unwatch'},
u'watch-topic': {u'title': u'Watch',
u'url': u'/w/index.php?title=Topic:S7hjfc3k6rz71qul&action=watch'}},
u'postId': u's7hjfc5wdfg7btil',
u'previousRevisionId': None,
u'properties': [],
u'replies': [],
u'replyToId': u's7hjfc3k6rz71qul',
u'revisionId': u's7hjfc5wdfg7btil',
u'size': {u'new': 82,
u'old': 0},
u'timestamp': u'20141207004658',
u'watchable': True,
u'workflowId': u's7hjfc3k6rz71qul'},
u's7xiyvrngzt6106l': {u'actions': {u'edit': {u'title': u'Edit title',
u'url': u'/w/index.php?title=Topic:S7xiyvpkn2y1s1t9&action=edit-title&topic_revId=s7xiyvrngzt6106l'},
u'hide': {u'title': u'Hide topic',
u'url': u'/w/index.php?title=Topic:S7xiyvpkn2y1s1t9&action=moderate-topic&topic_moderationState=hide'},
u'lock': {u'title': u'Lock topic',
u'url': u'/w/index.php?title=Topic:S7xiyvpkn2y1s1t9&action=lock-topic&flow_moderationState=lock'},
u'reply': {u'title': u'Reply',
u'url': u'/w/index.php?title=Topic:S7xiyvpkn2y1s1t9&action=reply&topic_postId=s7xiyvpkn2y1s1t9#flow-reply-s7xiyvpkn2y1s1t9'},
u'summarize': {u'title': u'Summarize',
u'url': u'/w/index.php?title=Topic:S7xiyvpkn2y1s1t9&action=edit-topic-summary'}},
u'author': {u'gender': u'unknown',
u'id': 25407,
u'links': {u'contribs': {u'exists': True,
u'title': u'Contributions/Fhocutt bot',
u'url': u'/wiki/Special:Contributions/Fhocutt_bot'},
u'talk': {u'exists': False,
u'title': u'User talk:Fhocutt bot',
u'url': u'/wiki/User_talk:Fhocutt_bot'},
u'userpage': {u'exists': False,
u'title': u'Fhocutt bot',
u'url': u'/wiki/User:Fhocutt_bot'}},
u'name': u'Fhocutt bot',
u'wiki': u'testwiki'},
u'changeType': u'new-post',
u'content': {u'content': u'test topic',
u'format': u'plaintext'},
u'creator': {u'gender': u'unknown',
u'id': 25407,
u'links': {u'contribs': {u'exists': True,
u'title': u'Contributions/Fhocutt bot',
u'url': u'/wiki/Special:Contributions/Fhocutt_bot'},
u'talk': {u'exists': False,
u'title': u'User talk:Fhocutt bot',
u'url': u'/wiki/User_talk:Fhocutt_bot'},
u'userpage': {u'exists': False,
u'title': u'Fhocutt bot',
u'url': u'/wiki/User:Fhocutt_bot'}},
u'name': u'Fhocutt bot',
u'wiki': u'testwiki'},
u'dateFormats': [],
u'isMaxThreadingDepth': False,
u'isModerated': False,
u'isOriginalContent': True,
u'isWatched': True,
u'lastEditId': None,
u'lastEditUser': {u'gender': u'unknown',
u'id': None,
u'links': [],
u'name': None,
u'wiki': None},
u'last_updated': 1418533299000,
u'last_updated_readable': u'05:01, 14 December 2014',
u'links': {u'post': {u'title': u'post',
u'url': u'/w/index.php?title=Topic:S7xiyvpkn2y1s1t9&topic_showPostId=s7xiyvpkn2y1s1t9#flow-post-s7xiyvpkn2y1s1t9'},
u'topic': {u'title': u'topic',
u'url': u'/wiki/Topic:S7xiyvpkn2y1s1t9'},
u'topic-history': {u'title': u'History',
u'url': u'/w/index.php?title=Topic:S7xiyvpkn2y1s1t9&action=history'},
u'topic-revision': {u'title': u'topic revision',
u'url': u'/w/index.php?title=Topic:S7xiyvpkn2y1s1t9&topic_revId=s7xiyvrngzt6106l&action=single-view'},
u'unwatch-topic': {u'title': u'Unwatch',
u'url': u'/w/index.php?title=Topic:S7xiyvpkn2y1s1t9&action=unwatch'},
u'watch-topic': {u'title': u'Watch',
u'url': u'/w/index.php?title=Topic:S7xiyvpkn2y1s1t9&action=watch'}},
u'postId': u's7xiyvpkn2y1s1t9',
u'previousRevisionId': None,
u'properties': {u'topic-of-post': {u'plaintext': u'test topic'}},
u'replies': [u's7xiyvswokeyuey5'],
u'replyToId': None,
u'reply_count': 1,
u'revisionId': u's7xiyvrngzt6106l',
u'size': {u'new': 10,
u'old': 0},
u'timestamp': u'20141214050139',
u'watchable': True,
u'workflowId': u's7xiyvpkn2y1s1t9'},
u's7xiyvswokeyuey5': {u'actions': {u'edit': {u'title': u'Edit',
u'url': u'/w/index.php?title=Topic:S7xiyvpkn2y1s1t9&action=edit-post&topic_postId=s7xiyvswokeyuey5&topic_revId=s7xiyvswokeyuey5#flow-post-s7xiyvswokeyuey5'},
u'hide': {u'title': u'Hide',
u'url': u'/w/index.php?title=Topic:S7xiyvpkn2y1s1t9&action=moderate-post&topic_postId=s7xiyvswokeyuey5&topic_moderationState=hide'},
u'reply': {u'title': u'Reply',
u'url': u'/w/index.php?title=Topic:S7xiyvpkn2y1s1t9&action=reply&topic_postId=s7xiyvswokeyuey5#flow-post-s7xiyvswokeyuey5'},
u'summarize': {u'title': u'Summarize',
u'url': u'/w/index.php?title=Topic:S7xiyvpkn2y1s1t9&action=edit-topic-summary'}},
u'author': {u'gender': u'unknown',
u'id': 25407,
u'links': {u'contribs': {u'exists': True,
u'title': u'Contributions/Fhocutt bot',
u'url': u'/wiki/Special:Contributions/Fhocutt_bot'},
u'talk': {u'exists': False,
u'title': u'User talk:Fhocutt bot',
u'url': u'/wiki/User_talk:Fhocutt_bot'},
u'userpage': {u'exists': False,
u'title': u'Fhocutt bot',
u'url': u'/wiki/User:Fhocutt_bot'}},
u'name': u'Fhocutt bot',
u'wiki': u'testwiki'},
u'changeType': u'reply',
u'content': {u'content': u'<p data-parsoid=\'{"dsr":[0,12,0,0]}\'>test message</p>',
u'format': u'html'},
u'creator': {u'gender': u'unknown',
u'id': 25407,
u'links': {u'contribs': {u'exists': True,
u'title': u'Contributions/Fhocutt bot',
u'url': u'/wiki/Special:Contributions/Fhocutt_bot'},
u'talk': {u'exists': False,
u'title': u'User talk:Fhocutt bot',
u'url': u'/wiki/User_talk:Fhocutt_bot'},
u'userpage': {u'exists': False,
u'title': u'Fhocutt bot',
u'url': u'/wiki/User:Fhocutt_bot'}},
u'name': u'Fhocutt bot',
u'wiki': u'testwiki'},
u'dateFormats': [],
u'isMaxThreadingDepth': False,
u'isModerated': False,
u'isOriginalContent': True,
u'isWatched': False,
u'lastEditId': None,
u'lastEditUser': {u'gender': u'unknown',
u'id': None,
u'links': [],
u'name': None,
u'wiki': None},
u'links': {u'post': {u'title': u'post',
u'url': u'/w/index.php?title=Topic:S7xiyvpkn2y1s1t9&topic_showPostId=s7xiyvswokeyuey5#flow-post-s7xiyvswokeyuey5'},
u'post-revision': {u'title': u'post revision',
u'url': u'/w/index.php?title=Topic:S7xiyvpkn2y1s1t9&topic_postId=s7xiyvswokeyuey5&topic_revId=s7xiyvswokeyuey5&action=single-view'},
u'topic': {u'title': u'topic',
u'url': u'/wiki/Topic:S7xiyvpkn2y1s1t9'},
u'topic-history': {u'title': u'History',
u'url': u'/w/index.php?title=Topic:S7xiyvpkn2y1s1t9&action=history'},
u'unwatch-topic': {u'title': u'Unwatch',
u'url': u'/w/index.php?title=Topic:S7xiyvpkn2y1s1t9&action=unwatch'},
u'watch-topic': {u'title': u'Watch',
u'url': u'/w/index.php?title=Topic:S7xiyvpkn2y1s1t9&action=watch'}},
u'postId': u's7xiyvswokeyuey5',
u'previousRevisionId': None,
u'properties': [],
u'replies': [],
u'replyToId': u's7xiyvpkn2y1s1t9',
u'revisionId': u's7xiyvswokeyuey5',
u'size': {u'new': 53,
u'old': 0},
u'timestamp': u'20141214050139',
u'watchable': True,
u'workflowId': u's7xiyvpkn2y1s1t9'}},
u'roots': [u's7xiyvpkn2y1s1t9',
u's7hjfc3k6rz71qul'],
u'sortby': u'newest',
u'submitted': {u'content': u'test message',
u'token': u'47258712d7df998c756a9b5bfcd937b4548d19b2+\\',
u'topic': u'test topic'},
u'title': u'Wikipedia:Co-op/Mentorship match',
u'type': u'topiclist',
u'workflowId': u's7hjfbzj7bjwke99'}},
u'status': u'ok',
u'workflow': u's7hjfbzj7bjwke99'}}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment