Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const request = require('request').defaults({jar: true})
- const url = "https://en.wikipedia.org/w/api.php"
- const csrf_token = // output of mw.user.tokens.get('csrfToken') from my JS console
- const params = {
- action: "edit",
- title: "User:Satricious/sandbox",
- appendtext: "test edit",
- token: csrf_token,
- format: "json"
- }
- request.post({ url: url, form: params }, (error, res, body) => {
- if (error) return
- console.log(body)
- })
- /* The output I get:
- {"error":{"code":"badtoken","info":"Invalid CSRF token.","*":"See https://en.wikipedia.org/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/postorius/lists/mediawiki-api-announce.lists.wikimedia.org/> for notice of API deprecations and breaking changes."},"servedby":"mw1343"}
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement