我完成这篇Laravel 4 REST类型的教程在这里 - http://code.tutsplus.com/tutorials/laravel-4-a-start-at-a-restful-api-updated--net-29785调用Laravel在浏览器网址4宁静的卷曲
我想要做的就是测试浏览器的URL链接宁静:
curl命令:
$ curl -i --user firstuser:first_password -d 'url=hxxp://google.com&description=A Search Engine' www.lrvlapp.com/api/v1/url
这是运行正常,并返回预期的JSON:
{"error":false,"message":"URL created"}
浏览器网址:我试试这个:
www.lrvlapp.com/api/v1/url?url=hxxp://google.com&description=A Search Engine
没有错误或任何东西,并给出任何URL插入到数据库中。
这是UrlController
类UrlController扩展\ {BaseController
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
return 'Hello, API';
}
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$url = new Url;
$url->url = Request::get('url');
$url->description = Request::get('description');
$url->user_id = Auth::user()->id;
// Validation and Filtering is sorely needed!!
// Seriously, I'm a bad person for leaving that out.
$url->save();
return Response::json(array(
'error' => false,
'message' => 'URL created')
);
}
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
//
}
}
www.lrvlapp.com实际上是通过主机我的虚拟主机我的设置文件和Apache虚拟主机
实际位置是:c:\ xampp \ htdocs \ lrvlapp \ public
谢谢你的回答
你只是得到一个空白的屏幕? – Mediabeastnz
是的,拿到了空白屏幕 –
你是什么把一个回声'你好';死();在函数store()中。这会得到回应吗? – Mediabeastnz