Activity api of buddypress

 

Here are the details for the BuddyPress Activity API, including endpoints to retrieve and manage activities.


1. Get Activity Stream

Endpoint:

http://127.0.0.1/wordpress/wp-json/buddypress/v1/activity

Request Parameters:

Parameter Type Required Description
user_id Integer No The ID of the user for whom to get activity.
per_page Integer No Number of activities per page (default is 20).
page Integer No Page number for pagination.
type String No Filter activities by type (e.g., activity_update).

Example Request (Get Activity for a Specific User):

curl -X GET "http://127.0.0.1/wordpress/wp-json/buddypress/v1/activity?user_id=1&per_page=5&page=1" \
-H "Authorization: Bearer YOUR_TOKEN"

Example Response:

{
  "activities": [
    {
      "id": 1,
      "user_id": 1,
      "content": "User 1 posted an activity.",
      "date": "2025-01-03T10:30:00",
      "type": "activity_update",
      "url": "http://127.0.0.1/wordpress/activity/1",
      "author_name": "User 1",
      "author_avatar": "http://127.0.0.1/wp-content/uploads/avatars/1/avatar.jpg"
    },
    {
      "id": 2,
      "user_id": 2,
      "content": "User 2 posted an activity.",
      "date": "2025-01-02T09:15:00",
      "type": "activity_update",
      "url": "http://127.0.0.1/wordpress/activity/2",
      "author_name": "User 2",
      "author_avatar": "http://127.0.0.1/wp-content/uploads/avatars/2/avatar.jpg"
    }
  ]
}

2. Create an Activity (Post a New Activity)

Endpoint:

http://127.0.0.1/wordpress/wp-json/buddypress/v1/activity

Request Payload:

Parameter Type Required Description
content String Yes The content of the activity post.
user_id Integer Yes The ID of the user posting the activity.
type String No The type of the activity (e.g., activity_update).

Example Request (Post a New Activity):

curl -X POST "http://127.0.0.1/wordpress/wp-json/buddypress/v1/activity" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
  "content": "User 1 just created a new activity.",
  "user_id": 1,
  "type": "activity_update"
}'

Example Response:

{
  "activity": {
    "id": 3,
    "user_id": 1,
    "content": "User 1 just created a new activity.",
    "date": "2025-01-03T14:00:00",
    "type": "activity_update",
    "url": "http://127.0.0.1/wordpress/activity/3",
    "author_name": "User 1",
    "author_avatar": "http://127.0.0.1/wp-content/uploads/avatars/1/avatar.jpg"
  }
}

3. Get a Specific Activity

Endpoint:

http://127.0.0.1/wordpress/wp-json/buddypress/v1/activity/<activity_id>

Example Request (Get Activity with ID 3):

curl -X GET "http://127.0.0.1/wordpress/wp-json/buddypress/v1/activity/3" \
-H "Authorization: Bearer YOUR_TOKEN"

Example Response:

{
  "activity": {
    "id": 3,
    "user_id": 1,
    "content": "User 1 just created a new activity.",
    "date": "2025-01-03T14:00:00",
    "type": "activity_update",
    "url": "http://127.0.0.1/wordpress/activity/3",
    "author_name": "User 1",
    "author_avatar": "http://127.0.0.1/wp-content/uploads/avatars/1/avatar.jpg"
  }
}

4. Delete an Activity

Endpoint:

http://127.0.0.1/wordpress/wp-json/buddypress/v1/activity/<activity_id>

Example Request (Delete Activity with ID 3):

curl -X DELETE "http://127.0.0.1/wordpress/wp-json/buddypress/v1/activity/3" \
-H "Authorization: Bearer YOUR_TOKEN"

Example Response:

{
  "deleted": true,
  "activity": {
    "id": 3,
    "user_id": 1,
    "content": "User 1 just created a new activity.",
    "date": "2025-01-03T14:00:00",
    "type": "activity_update",
    "url": "http://127.0.0.1/wordpress/activity/3",
    "author_name": "User 1",
    "author_avatar": "http://127.0.0.1/wp-content/uploads/avatars/1/avatar.jpg"
  }
}

5. Get Activity Types (List All Activity Types)

Endpoint:

http://127.0.0.1/wordpress/wp-json/buddypress/v1/activity/types

Example Request:

curl -X GET "http://127.0.0.1/wordpress/wp-json/buddypress/v1/activity/types" \
-H "Authorization: Bearer YOUR_TOKEN"

Example Response:

{
  "activity_types": [
    "activity_update",
    "friendship_request",
    "group_invite",
    "group_membership_request",
    "mention",
    "status_update"
  ]
}

Summary of Full Links

Action Full Link Method Payload (Example)
Get Activity Stream http://127.0.0.1/wordpress/wp-json/buddypress/v1/activity GET (Use user_id, per_page, page, and type parameters)
Create an Activity http://127.0.0.1/wordpress/wp-json/buddypress/v1/activity POST { "content": "User 1 activity", "user_id": 1, "type": "activity_update" }
Get Specific Activity http://127.0.0.1/wordpress/wp-json/buddypress/v1/activity/<id> GET (Use activity_id parameter)
Delete an Activity http://127.0.0.1/wordpress/wp-json/buddypress/v1/activity/<id> DELETE (No payload, just use activity_id)
Get Activity Types http://127.0.0.1/wordpress/wp-json/buddypress/v1/activity/types GET (No payload)

Let me know if you need more details or further assistance!

Comments

Popular posts from this blog

Frida Server Setup And Audit Syscalls of Android Application

ডপলার ক্রিয়া

Biot-Savart এর সূত্র (৪)