Back End Rest api for blog
create a database
composer install
php artisan migrate
for linux user and mac
cp .env .env.example
for windows user
copy .env.example .env
generate application key
php artisan key:generate
edit .env file
DB_DATABASE={databasename}
DB_USERNAME={username}
DB_PASSWORD={password}
now migrate database
php artisan migrate
POST http://{yourdomain}/api/register HTTP/1.1
content-type: application/json
Accept: application/json
{
"name": "testUser1",
"email": "testUser@gmail.com",
"password": "password"
}
POST http://{yourdomain}/api/login HTTP/1.1
content-type: application/json
Accept: application/json
{
"email": "aung@gmail.com",
"password": "password"
}
This request will response Token
POST http://{yourdomain}/api/post HTTP/1.1
content-type: application/json
Accept: application/json
Authorization: Bearer xxx
{
"title" : "lorem",
"body" : "lorem ipsum sit"
}
PATCH http://{yourdomain}/api/post/update/1 HTTP/1.1
content-type: application/json
Accept: application/json
Authorization: Bearer xxx
{
"title" : "lorem 222",
"body" : "lorem ipsum sit"
}
DELETE http://{yourdoamin}/api/post/delete/1 HTTP/1.1
content-type: application/json
Accept: application/json
Authorization: Bearer xxx
{
"title" : "lorem 222",
"body" : "lorem ipsum sit"
}
GET http://{yourdomain}/api/getPost HTTP/1.1
content-type: application/json
Authorization: Bearer xxx
Accept: application/json
POST http://{yourdomain}/api/comment HTTP/1.1
content-type: application/json
Accept: application/json
Authorization: Bearer xxx
{
"body" : "lorem ipsum sit",
"post_id" : {postID}
}
GET http://{yourdomain}/api/posts HTTP/1.1
content-type: application/json
Accept: application/json
GET http://{yourdomain}/api/post/1 HTTP/1.1
content-type: application/json
Accept: application/json
reply a comment
POST http://{yourdomain}/api/reply HTTP/1.1
content-type: application/json
Accept: application/json
Authorization: Bearer xxx
{
"body" : "this is reply for comment",
"comment_id" : {commentId}
}