通过代码插入文章。 完全新生,不知道怎么做。
使用Request组件来设定文章信息,然后调用Widget_Contents_Post_Edit组价来进行文章导入。
$request->setParams(
array(
'title'=>$title,
'text'=>$text,
...
)
);
//执行添加文章操作
$widgetName = 'Widget_Contents_Post_Edit';
$reflectionWidget = new ReflectionClass($widgetName);
if ($reflectionWidget->implementsInterface('Widget_Interface_Do')) {
$this->widget($widgetName)->action();
echo 'Successful';
return;
}
更加详细的过程,请看这里 调用typecho的API插入文章
码字不易,求采纳~~
如果暴露了action接口,被人恶意请求怎么办?