【发布时间】:2015-09-03 14:50:27
【问题描述】:
我的目标是使用提供的 REST API 在 confluence wiki 中创建一个包含表格的页面,该 wiki 用户可以在页面创建后使用 WYSIWYG 编辑器轻松编辑该表格。
我把文本拆开,分门别类放入数组数组中,然后从中生成一个html表格(一个字符串),效果很好。
但是将这个原始 html 表(在 $htmlTable 中)作为内容发布到 REST API
$data = array("type" => "page", "title" => someTitle,
"space" => array("key" => "$uploadSpace"),
"body" => array("storage" => array("value" => "$htmlTable", "representation" => "storage")));
返回 400 statusCode 错误。显然是因为使用 htmlspecialchars 将字符串编码为 html 没有正确转义输入,但是我将如何创建一个结构化的输入来转换为 html 表?
我尝试使用 confluence 宏传递我的 html 表,该宏将 html 输入呈现到表中以供查看:
$data = array("type" => "page", "title" => someTitle,
"space" => array("key" => "$uploadSpace"),
"body" => array("storage" => array("value" => "<ac:structured-macro ac:name=\"html\"><ac:plain-text-body><![CDATA[$htmlTable]]></ac:plain-text-body></ac:structured-macro>", "representation" => "storage")));
这会在页面上呈现我的 html 表格,但是这无法满足 WYSIWYG 要求中轻松编辑的要求,因为 wiki 的用户之后会看到包含在宏中的 html 代码。
非常感谢您。
【问题讨论】:
标签: php html rest confluence confluence-rest-api