1

メディア Wiki サイトの編集トークンにアクセスできません。次のコードを使用すると、simpleMediWiki サイトを使用してログインし、編集トークンを要求して、最後に編集をステージングできるはずです。残念ながら、「編集」パラメーターが認識されないパラメーターであるというエラーが表示されます。

{'error': {'info': "Unrecognized value for parameter 'action': token", 'code': 'unknown_action'}}

これが私のコードです:

from simplemediawiki import MediaWiki

wiki = MediaWiki('http://domain/api.php')
#the following logs me in
loginData = wiki.call({'action':'login', 'lgname':'myUserName','lgpassword':'myPassword'})

#The following is a resubmission of the login token
personalLoginData = wiki.call({'action':'login', 'lgname':'myUserName','lgpassword':'myPassword','lgtoken': loginData['login']['token']})

#the following is THE TROUBLESOME REQUEST FOR AN EDIT TOKEN
editTokenDict = wiki.call({'action':'tokens','type':'edit'}) 

#the following is an edit
results = wiki.call({'action':'edit','title':"ArticleTitle",'text':"This is the page",'tokens':editTokenDict['login']['token']})
4

1 に答える 1

0

答えは、mediaWiki 1.19.2 がこのクエリ オプションをサポートしていないことです。mediaWiki の最新リリースはこのクエリ オプションをサポートしていますが、それ以外の場合は、クエリ アクションを使用して編集トークンにアクセスする必要があります。例えば:

returnData = wiki.call({'action':'query','prop':'info', 'titles':'Main_Page','intoken':'edit'});

#keep in mind the edittoken is the same for every page, and that's why we preform the query action on the Main_Page
#then you must use the following to get the edittoken: 

edittoken = returnData['query']['pages']['1']['edittoken'] 
于 2012-11-14T08:00:16.643 に答える