Sử dụng lệnh curl, api thêm người dùng bằng api (ok)

$ curl -X POST http://blog.com/api/register -H "Accept: application/json" -H "Content-Type: application/json" -d '{"name": "LionelPhan10", "email": "lionel10@gmail.com", "password": "toptal"}'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   307  100   230  100    77    513    171 --:--:-- --:--:-- --:--:--   686{"data":{"name":"LionelPhan10","email":"lionel10@gmail.com","updated_at":"2020-07-25T18:52:03.000000Z","created_at":"2020-07-25T18:52:03.000000Z","id":21,"api_token":"K9cigx0EQwJAmgnjL9Rwx2ULFs0CSkf6Lief0fcTQ3gq2d0HU23b9tbJ89Nd"}}

C:\xampp\htdocs\blog\routes\api.php

<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
Use App\Article;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Route::get('articles', 'ArticleController@index');
Route::get('articles/{id}', 'ArticleController@show');
Route::post('articles', 'ArticleController@store');
Route::put('articles/{id}', 'ArticleController@update');
Route::delete('articles/{id}', 'ArticleController@delete');
Route::post('register', 'Auth\RegisterController@register');
Route::post('login', 'Auth\LoginController@login');

C:\xampp\htdocs\blog\app\Http\Controllers\Auth\RegisterController.php

C:\xampp\htdocs\blog\app\Http\Controllers\Auth\LoginController.php

C:\xampp\htdocs\blog\app\User.php

Last updated

Was this helpful?