简体   繁体   English

Mediawiki api登录不接受令牌

[英]Mediawiki api login doesn't accept token

I'm trying to authenticate to the mediawiki api, but it doesn't accept the login token I requested. 我正在尝试对mediawiki api进行身份验证,但它不接受我请求的登录令牌。 When I request (via POST) the token like this action=query&meta=tokens&type=login&format=json it returns me aa token, for example 当我请求(通过POST)令牌像这个action=query&meta=tokens&type=login&format=json它返回一个令牌,例如

batchcomplete:
query: {
    tokens: {
        logintoken: af69aa46ef0e505dca1b4b0ea696a55259258b4f+\
    }
}

But when I now try to authenticate with action=login&lgname=user&lgpassword=password&lgtoken=af69aa46ef0e505dca1b4b0ea696a55259258b4f%2B%5C&format=json I only getting this message back 但是当我现在尝试使用action=login&lgname=user&lgpassword=password&lgtoken=af69aa46ef0e505dca1b4b0ea696a55259258b4f%2B%5C&format=json进行身份验证时我只收到此消息

warnings: {
    main: {
        *: Subscribe to the mediawiki-api-announce mailing list at for notice of API deprecations and breaking changes. Use [Special:ApiFeatureUsage]] to see usage of deprecated features by your application.
    }
    login: {
        *: Fetching a token via "action=login" is deprecated. Use "action=query&meta=tokens&type=login" instead.
    }
}
login: {
    result: NeedToken
    token: a26aa15ecc99c421db73b86e7581497959258b4f+\
}

It seems like it's not recognizing the token. 似乎它没有识别令牌。 I'm using a bot password to login. 我正在使用机密密码登录。

Thanks for your help 谢谢你的帮助

Simon 西蒙

Tgr's comment solved my question: Tgr的评论解决了我的问题:

You need to issue the requests in the same session. 您需要在同一会话中发出请求。

How can I use sessions in a php script? 如何在php脚本中使用会话?

Depends on what you use for making web requests. 取决于您用于发出Web请求的内容。 With curl, you need to use the cookie jar + cookie file options. 使用curl,您需要使用cookie jar + cookie文件选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM