我完成這篇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