Php CRUD Restler柱从形式
*固定的*** 原来我的浏览器被缓存了!它一直在工作。我对代码所做的唯一更新是在注释发布后更新结果,这样我就可以在json响应中获得信息Php CRUD Restler柱从形式,php,html,forms,api,restler,Php,Html,Forms,Api,Restler,*固定的*** 原来我的浏览器被缓存了!它一直在工作。我对代码所做的唯一更新是在注释发布后更新结果,这样我就可以在json响应中获得信息 return $result->comment = array('video_id'=>"$video_id",'fb_id'=>"$fb_id",'comment'=>"$comment"); 我无法将表单中的值发布到restler。我不确定我做错了什么 当我尝试发布我的表格时,我会收到一份报税表: { "error":
return $result->comment = array('video_id'=>"$video_id",'fb_id'=>"$fb_id",'comment'=>"$comment");
我无法将表单中的值发布到restler。我不确定我做错了什么
当我尝试发布我的表格时,我会收到一份报税表:
{
"error": {
"code": 404,
"message": "Not Found"
}
}
以下是我的formcomment.html代码:
下面是我的classcomment.php的代码:
如果有人能帮忙的话,我所有的其他API调用对于GET来说都非常有用。这是我遇到麻烦的帖子。这个restler?不,这个restler-
<form action="http://mysite.com/api/index.php/comment" method="post">
<label>fb_id</label>
<input type="text" name="fb_id">
<label>video_id</label>
<input type="text" name="video_id">
<label>comment</label>
<input type="text" name="comment">
<input type="submit" value="Post" name="submit">
</form>
class Comment{
static $FIELDS = array('video_id', 'fb_id','comment');
public $restler;
public function insert($rec){
$video_id = mysql_escape_string($rec['video_id']);
$fb_id= mysql_escape_string($rec['fb_id']);
$comment = mysql_escape_string($rec['comment']);
$sql = "INSERT INTO comments(video_id,fb_id,comment) VALUES('$video_id','$fb_id','$comment')";
mysql_query($sql);
return 'Record Inserted';
}
public function post($request_data=NULL){
return $this->insert($this->_validate($request_data));
}
private function _validate($data){
$comment=array();
foreach (Comment::$FIELDS as $field) {
if(!isset($data[$field]))throw new RestException(417,"$field field missing");
$comment[$field]=$data[$field];
}
return $comment;
}
}