Skip to content

AdnanTech

Programming tutorials

  • Python
  • PHP
    • Laravel
    • WordPress
  • Javascript
    • React JS
    • Node.js
    • Vue JS
  • Databases
    • MySQL
    • MongoDB
  • Mobile apps
    • Android
    • iOS
  • Tutorials
    • Ticketing system
    • Chat app
  • Blog
  • Projects
  • API
    • Social network API
  • Services
    • Hash Generator
    • World Clock
    • Word Counter
    • Currency Converter
    • Financial Ledger
    • Time Difference
    • Stopwatch & Timer
    • Google Maps
  • SAAS
    • Job Entry

Posts

Social network is all about posting what you are doing or what you are thinking. Following APIs are included in posts modules:

  • Create post
  • Update post
  • Delete post
  • Toggle like (like or un-like)
  • Comment on post
  • Fetch all posts
  • Fetch single post
  • Fetch people who liked the post
  • Fetch people who commented on the post
  • Fetch people who has shared the post

Create post

Creates a post on social media with logged-in user’s account. This API can also be used for sharing the post as well, you just need to pass the shared_post_id having the ID of post that is being shared.

You can also upload attachments with the post. The attachments must be image or video file. If the privacy of post is private, then the attachments will be saved in private storage. Otherwise, they will be saved in public storage.

URL = http://localhost:8000/api/posts/create

Method = POST

Headers

Acceptapplication/json
AuthorizationBearer {access_token}

Parameters

KeyTypeRequired
captionstringNo
typestringNo
activitystringNo
activity_valuestringNo
with_userinteger0
shared_post_idinteger0
time_zonestringNo
  • type: Define if the post is public or private. Possible values:
    • private
    • public
  • activity: Tells if you are having any activity. Possible values:
    • Eating
    • Reading
    • Feeling
    • Playing
    • Doing
    • Going
  • activity_value: Specify what you are doing. For example, if the activity is “Playing”, then activity_value can be “Cricket”.
  • with_user: The ID of the user if you are going out with any of your friend.
  • shared_post_id: If you are sharing a post, then this will be the ID of original post. It’s default value is 0.

Response

Status = 200

{
    "status": "success",
    "message": "Post has been created.",
    "post": {
        "id": 11,
        "user_id": 2,
        "caption": "Posting in private.",
        "files": [
            {
                "path": "data:image/jpeg;base64,/9j/4AAQSkZJR...",
                "size": 124782,
                "type": "image/jpeg",
                "extension": "JPG"
            }
        ],
        "type": "private",
        "activity": "Playing",
        "activity_value": "Cricket",
        "likes": 0,
        "comments": 0,
        "shares": 0,
        "shared_post_id": 0,
        "created_at": "05 Oct, 2024 11:58:24 pm",
        "updated_at": "05 Oct, 2024 11:58:24 pm"
    }
}
  • In “files” array, the key “path” will be absolute URL if the post is public. If the post is private, then it will be a base64 string.

Update post

Updates already uploaded post of user’s post. You can add more images or videos with the post if you want.

URL = http://localhost:8000/api/posts/update

Method = POST

Headers

Acceptapplication/json
AuthorizationBearer {access_token}

Parameters

KeyTypeRequired
idintegerYes
captionstringNo
typestringNo
activitystringNo
activity_valuestringNo
with_userinteger0
shared_post_idinteger0
time_zonestringNo
  • id: The ID of the post that needs to be updated.

Response

Status = 200

{
    "status": "success",
    "message": "Post has been updated."
}

Delete post

Deletes the user’s post. All attached images and videos will be deleted as well.

URL = http://localhost:8000/api/posts/delete

Method = POST

Headers

Acceptapplication/json
AuthorizationBearer {access_token}

Parameters

KeyTypeRequired
idintegerYes
  • id: The ID of the post that needs to be deleted.

Response

Status = 200

{
    "status": "success",
    "message": "Post has been deleted."
}
  • This will also delete all the attached files with the post.

Toggle like (like or un-like)

Using this API, you can give reaction to a post. If you have already reacted to a post, then calling again this API will remove your reaction.

URL = http://localhost:8000/api/posts/toggle-like

Method = POST

Headers

Acceptapplication/json
AuthorizationBearer {access_token}

Parameters

KeyTypeRequired
idintegerYes
reactionstringYes
  • reaction: Defines how user has reacted to a post. Possible values:
    • like
    • love
    • angry
    • sad
    • laugh

Response

Status = 200

{
    "status": "success",
    "message": "Post has been liked."
}

Comment on post

Lets you comment on a post. Your comment will be returned in fetch-comments API in upcoming sections.

URL = http://localhost:8000/api/posts/comment

Method = POST

Headers

Acceptapplication/json
AuthorizationBearer {access_token}

Parameters

KeyTypeRequired
idintegerYes
commentstringYes
time_zonestringNo
  • id: The ID of the post.

Response

Status = 200

{
    "status": "success",
    "message": "Comment has been added.",
    "comment": {
        "id": 2,
        "comment": "Nice post.",
        "user_name": "Adnan Afzal",
        "user_profile_image": "http://localhost:8000/storage/users/2/profile-IMG_0025.JPG",
        "created_at": "05 Oct 2024, 11:16:25 pm"
    }
}

Fetch all posts

Fetches all public posts uploaded on social network in descending order. So the latest uploaded posts will be on top.

URL = http://localhost:8000/api/posts

Method = POST

Headers

Acceptapplication/json

Parameters

KeyTypeRequired
pageintegerYes

Response

Status = 200

{
    "status": "success",
    "message": "Data has been fetched.",
    "posts": [
        {
            "id": 16,
            "caption": "Sharing post.",
            "user_name": "Adnan Afzal",
            "profile_image": "http://localhost:8000/storage/users/2/profile-IMG_0025.JPG",
            "files": [
                {
                    "path": "http://localhost:8000/storage/posts/2024-10-05/972971344568756318_n.jpg",
                    "size": 114529,
                    "type": "image/jpeg",
                    "extension": "jpg"
                }
            ],
            "type": "public",
            "activity": "",
            "with_user": 0,
            "likes": 0,
            "comments": 0,
            "shares": 0,
            "shared_post": {
                "id": 15,
                "caption": "Posting in private.",
                "files": [
                    {
                        "path": "data:image/png;base64,iVBORw0KGgo...",
                        "size": 99584,
                        "type": "image/png",
                        "extension": "png"
                    }
                ],
                "activity": ""
            },
            "created_at": "5 minutes"
        }
    ]
}
  • If the post is not shared, then the “shared_post” value will be null.

Fetch single post

Return single post if it is public. It will also return the attachments added to that post. If the post has shared another post, then the shared post will be returned as well.

URL = http://localhost:8000/api/posts/fetch

Method = POST

Headers

Acceptapplication/json

Parameters

KeyTypeRequired
idintegerYes
time_zonestringNo

Response

Status = 200

{
    "status": "success",
    "message": "Data has been fetched.",
    "post": {
        "id": 16,
        "caption": "Sharing post.",
        "user_name": "Adnan Afzal",
        "profile_image": "http://localhost:8000/storage/users/2/profile-IMG_0025.JPG",
        "files": [],
        "type": "public",
        "activity": "",
        "with_user": 0,
        "likes": 0,
        "comments": 0,
        "shares": 0,
        "shared_post_id": 15,
        "shared_caption": "Posting in private.",
        "shared_files": [
            {
                "path": "data:image/png;base64,iVBORw0KGgoAAA...",
                "size": 99584,
                "type": "image/png",
                "extension": "png"
            }
        ],
        "shared_activity": "",
        "created_at": "29 minutes"
    }
}

Fetch people who liked the post

If you want to get the list of all users who has reacted to a post, you can call this API. It will return the user name and profile image along with his reaction on that post.

URL = http://localhost:8000/api/posts/fetch-likes

Method = POST

Headers

Acceptapplication/json

Parameters

KeyTypeRequired
idintegerYes
pageintegerYes

Response

Status = 200

{
    "status": "success",
    "message": "Data has been fetched.",
    "likers": [
        {
            "id": 2,
            "name": "Adnan Afzal",
            "reaction": "sad",
            "profile_image": "http://localhost:8000/storage/users/2/profile-IMG_0025.JPG"
        }
    ]
}

Fetch people who commented on the post

Just like getting the users who has reacted to a post, using this API you can get a list of all users who has commented on a post. It will also return user name and profile image along with the comment he has posted.

URL = http://localhost:8000/api/posts/fetch-comments

Method = POST

Headers

Acceptapplication/json

Parameters

KeyTypeRequired
idintegerYes
pageintegerYes
time_zonestringNo

Response

Status = 200

{
    "status": "success",
    "message": "Data has been fetched.",
    "comments": [
        {
            "id": 3,
            "comment": "Nice post.",
            "user_name": "Adnan Afzal",
            "user_profile_image": "http://localhost:8000/storage/users/2/profile-IMG_0025.JPG",
            "created_at": "05 Oct 2024, 11:29:49 pm"
        }
    ]
}

Fetch people who has shared the post

Returns the posts that has shared a post. This will return the post shared when you call the posts/create API and pass the shared_post_id value other than 0.

URL = http://localhost:8000/api/posts/fetch-shares

Method = POST

Headers

Acceptapplication/json

Parameters

KeyTypeRequired
idintegerYes
pageintegerYes
time_zonestringNo

Response

Status = 200

{
    "status": "success",
    "message": "Data has been fetched.",
    "posts": [
        {
            "id": 16,
            "caption": "Sharing post.",
            "user_id": 2,
            "user_name": "Adnan Afzal",
            "user_profile_image": "http://localhost:8000/storage/users/2/profile-1727853217-IMG_0025.JPG",
            "created_at": "05 Oct, 2024 11:23:22 pm"
        }
    ]
}
previous

Recent Posts

  • Show selected images from input type file – React
  • Add dynamic rows in React
  • Soft Delete 🗑 – Node.js, MongoDB
  • 2 ways to loop through a number in React
  • Get updated value from Child to Parent – React

Recent Comments

  1. canada pharmaceuticals online generic on PDF view in browser and export as file – PHP
  2. System on (no title)
  3. adnanafzal565 on (no title)
  4. adnanafzal565 on (no title)
  5. System on (no title)

Archives

  • May 2025
  • March 2025
  • February 2025
  • January 2025
  • November 2024
  • September 2024
  • August 2024
  • July 2024
  • June 2024
  • May 2024
  • April 2024
  • March 2024
  • February 2024
  • January 2024
  • November 2023
  • September 2023
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020

Categories

  • Android
  • Complete Projects
  • CSS
  • FFmpeg
  • Git
  • htaccess
  • HTML
  • iOS
  • Javascript
  • Laravel
  • Leap Motion Controller
  • MEVN
  • MongoDB
  • MySQL
  • Node.js
  • PHP
  • Python
  • React JS
  • Swift
  • Tips & Tricks
  • Uncategorized
  • Vue JS
  • WordPress
2019-2025
support@adnan-tech.com