我正在尝试使用Parsoid将 wikitext 转换为 HTML 。
运行服务器:
/usr/bin/nodejs /usr/lib/parsoid/src/bin/server.js \
-c /etc/mediawiki/parsoid/config.yaml
配置部分:
# Allow override of port/interface:
serverPort: 8877
serverInterface: '127.0.0.1'
PHP脚本:
$data = array("wikitext" => "'''Foo'''");
$data_string = json_encode($data);
$ch = curl_init('http://localhost:8877/v3/transform/wikitext/to/html/');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$result = curl_exec($ch);
echo $result;
结果:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot POST /v3/transform/wikitext/to/html/</pre>
</body>
</html>
问:我在做什么错了?