将下面的代码保存为main.php 并保存到 /app/fabu/
代码:
<?php //接口密码 define('PW', '采集密码'); if($_POST['password'] !== PW) die('接口密码错误!'); if (!defined('IN_ANWSION')) { die; } class main extends AWS_CONTROLLER { public function get_access_rule() { $rule_action['rule_type'] = 'black'; return $rule_action; } public function setup() { HTTP::no_cache_header(); } public function index_action() { $title=$_POST['title']; $content = $_POST['contents']; $uid = 2; $topics1 = explode(',',$_POST['topics']) ; if(isset($topics1)){ foreach($topics1 as $t1) $topic[] = $t1; } //$topic[]=$_POST['topics']; $catId=$_POST['cateId']; $attach_access_key = md5(uniqid() . microtime(true)); $content = trim($content); if(empty($content)){ die('空文章内容'); } $content = str_replace(array("/r/n", "/r", "/n"), '', $content); $content = str_replace("\r", '', $content); $content = str_replace("\n", '', $content); $content = str_replace(' ', '', $content); $content = str_replace("\r\n", '', $content); print_r($content); //public function publish_article($title, $message,$shortContent,$firstImg, $uid, $topics = null, $category_id = null, $attach_access_key = null, $create_topic = true) $question_id = $this->model('publish')->publish_article($title,'',$content, $uid,$topic, $catId, $attach_access_key, true); echo $question_id ; } } ?>
一共五个参数:
title 标题
contents 文章内容
topics 话题,使用逗号分隔
cateId 分类ID
password 代码中设置的密码。
使用post提交到 http://你的网址/fabu/
原创申明:本文章为三叔原创。