Index: trunk/extensions/LiquidThreads/api/ApiThreadAction.php |
— | — | @@ -5,6 +5,13 @@ |
6 | 6 | public function execute() { |
7 | 7 | $params = $this->extractRequestParams(); |
8 | 8 | |
| 9 | + if ( isset( $params['gettoken'] ) ) { |
| 10 | + global $wgUser; |
| 11 | + $result = array( 'token' => $wgUser->editToken() ); |
| 12 | + $this->getResult()->addValue( null, 'threadaction', $result ); |
| 13 | + return; |
| 14 | + } |
| 15 | + |
9 | 16 | if ( empty( $params['threadaction'] ) ) { |
10 | 17 | $this->dieUsageMsg( array( 'missingparam', 'action' ) ); |
11 | 18 | } |
— | — | @@ -917,6 +924,7 @@ |
918 | 925 | 'value' => null, |
919 | 926 | 'method' => null, |
920 | 927 | 'operand' => null, |
| 928 | + 'gettoken' => null, |
921 | 929 | ); |
922 | 930 | } |
923 | 931 | |
Index: trunk/extensions/LiquidThreads/lqt.js |
— | — | @@ -886,16 +886,14 @@ |
887 | 887 | 'getToken' : function( callback ) { |
888 | 888 | var getTokenParams = |
889 | 889 | { |
890 | | - 'action' : 'query', |
891 | | - 'prop' : 'info', |
892 | | - 'intoken' : 'edit', |
893 | | - 'titles' : 'Some Title', |
| 890 | + 'action' : 'threadaction', |
| 891 | + 'gettoken' : 'gettoken', |
894 | 892 | 'format' : 'json' |
895 | 893 | }; |
896 | 894 | |
897 | | - $j.get( wgScriptPath+'/api'+wgScriptExtension, getTokenParams, |
| 895 | + $j.post( wgScriptPath+'/api'+wgScriptExtension, getTokenParams, |
898 | 896 | function( data ) { |
899 | | - var token = data.query.pages[-1].edittoken; |
| 897 | + var token = data.threadaction.token; |
900 | 898 | |
901 | 899 | callback(token); |
902 | 900 | }, 'json' ); |