无法获取 MediaWiki api 的编辑令牌
我无法获得 MediaWiki 的编辑令牌:
请求
POST /w/api.php HTTP/1.1
Host: en.wikipedia.org
Accept: */*
User-agent: Sbose7890
Content-Length: 59
Content-Type: application/x-www-form-urlencoded
action=query&prop=info&intoken=edit&titles=Java&format=json
响应
HTTP/1.0 200 OK
Date: Tue, 10 Jan 2012 09:14:03 GMT
Server: Apache
X-Content-Type-Options: nosniff
Cache-Control: private
Vary: Accept-Encoding
Content-Length: 209
Content-Type: application/json; charset=utf-8
X-Cache: MISS from sq34.wikimedia.org
X-Cache-Lookup: MISS from sq34.wikimedia.org:3128
X-Cache: MISS from sq59.wikimedia.org
X-Cache-Lookup: MISS from sq59.wikimedia.org:80
Connection: close
{
"query": {
"pages": {
"69336": {
"starttimestamp": "2012-01-10T09:14:03Z",
"lastrevid": 469959190,
"touched": "2012-01-07T11:38:04Z",
"pageid": 69336,
"title": "Java",
"edittoken": "+\\",
"ns": 0,
"length": 37800,
"counter": ""
}
}
}
}
我使用 hurl.it。
我也登录了。
I'm not being able to obtain an edit token for MediaWiki:
Request
POST /w/api.php HTTP/1.1
Host: en.wikipedia.org
Accept: */*
User-agent: Sbose7890
Content-Length: 59
Content-Type: application/x-www-form-urlencoded
action=query&prop=info&intoken=edit&titles=Java&format=json
Response
HTTP/1.0 200 OK
Date: Tue, 10 Jan 2012 09:14:03 GMT
Server: Apache
X-Content-Type-Options: nosniff
Cache-Control: private
Vary: Accept-Encoding
Content-Length: 209
Content-Type: application/json; charset=utf-8
X-Cache: MISS from sq34.wikimedia.org
X-Cache-Lookup: MISS from sq34.wikimedia.org:3128
X-Cache: MISS from sq59.wikimedia.org
X-Cache-Lookup: MISS from sq59.wikimedia.org:80
Connection: close
{
"query": {
"pages": {
"69336": {
"starttimestamp": "2012-01-10T09:14:03Z",
"lastrevid": 469959190,
"touched": "2012-01-07T11:38:04Z",
"pageid": 69336,
"title": "Java",
"edittoken": "+\\",
"ns": 0,
"length": 37800,
"counter": ""
}
}
}
}
I tried it out using hurl.it.
I'm also logged in.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您将获得一个编辑令牌:
+\
。这是针对匿名用户的,并且始终相同。请参阅 mw:Manual:编辑令牌,以及从那里链接的修订版本。问题是,无论您是否登录,hurl 都必须登录。它必须发送一个有效的
enwiki_session
cookie,例如您的。但不要发布你的,每个人都可以用它登录!You are getting an edit token:
+\
. This is the one for anon users, and is always the same. See mw:Manual:Edit token, and also the revisions linked from there.The problem is that it's regardless of your login, hurl must be logged in. It would have to send a valid
enwiki_session
cookie, yours for example. But do not publish yours, everybody could login with it!简而言之,不要使用原始 MediaWiki API,每个都有客户端可以想象的语言可以为您处理所有这些乏味的事情。例如,如果您使用 Ruby,这里是您需要的所有 MediaWiki::Gateway 代码登录并编辑文章:
In short, do not use the raw MediaWiki API, there are clients for every conceivable language out there which take care of all this tedious stuff for you. For example, if you're using Ruby, here's all the MediaWiki::Gateway code you need to log in and edit an article: