MediaWiki API and Coding

I use the MediaWiki API to refresh some pages with an experimental robot. This robot uses the Apache Java Java client library to refresh pages.

(...)
PostMethod postMethod = new PostMethod("http://mymediawikiinstallation/w/api.php");
postMethod.addParameter("action","edit");
postMethod.addParameter("title",page.replace(' ', '_'));
postMethod.addParameter("summary","trying to fix this accent problem");
postMethod.addParameter("text",content);
postMethod.addParameter("basetimestamp",basetimestamp);
postMethod.addParameter("starttimestamp",starttimestamp);
postMethod.addParameter("token",token);
postMethod.addParameter("notminor","");
postMethod.addParameter("format","xml");
int status = httpClient.executeMethod(postMethod);
(...)

However, the string "content" contains some accents. System.out.prinln(content)It looks fine, but accented characters on the wiki look bad. For example. "Val rie" instead of "Valérie".

How can i fix this?

+5
source share
2 answers

OK, changing the request header fixed the problem.

postMethod.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
+3
source

PHP- API- Mediawiki urlencode title, , , .

0

All Articles