Skip to main content

Overview

This document provides instructions for creating posts related to companies on the LikeMinds platform. It covers two scenarios:

  1. Creating a post for a new company widget (when the company widget does not exist).
  2. Creating a post for an existing company widget.

It also includes a section on fetching widgets for a specific company using the unique company identifier. The document provides detailed steps, including API endpoints, request payloads, and cURL examples for each scenario.

The key steps involved are:

  • Generating an authentication token (auth_token) for the company owner.
  • Creating a post with the necessary details and metadata.
  • Attaching the company widget information to the post payload.
  • Fetching the existing company widget (if applicable) to obtain the widget ID.

The document emphasizes the importance of using the correct authentication token and payload structures for each API request.

Create posts for a company

Create Post for a New Company Widget (If the company widget does not already exist)

  1. Create the company owner's auth_token using the sdk/initiate API and retrieve the access_token from the response. (Use the credentials of the company owner - user_name & user_unique_id)

  2. Create a post with all the post details (refer to the document: Likeminds - Client feed Data Migration) and include the metadata of the company in the request body.

  3. Call the feed/post API (POST) with a new attachment in the attachments array of the request body:

  • attachment_type: 5

  • attachment_meta: Metadata of the company in JSON format

        curl --location --request POST 'https://auth.likeminds.community/feed/post' \
    --header 'Authorization: <auth_token>' \
    --header 'Content-Type: application/json' \
    --data '{
    "text": "New post with company widget",
    "attachments" : [
    { // existing attachments (i.e - img, video, etc)
    "attachment_type": 1,
    "attachment_meta" : {
    "name": "name",
    "url" : "url"
    }
    },
    { // company widget attachment
    "attachment_type" : 5,
    "attachment_meta" : {
    'company_id': "id", // This should be unique
    'company_name': "name",
    'company_image_url': "imageUrl",
    'company_description': "description",
    }
    }
    ]
    } '

Create Post for an Existing Company Widget

  1. For a company, fetch its widget using the mentioned "Fetch Widgets" flow.

  2. From the response object, store/copy the _id (company widget id).

  3. Create the company owner's auth_token using the sdk/initiate API and retrieve the access_token from the response. (Use the credentials of the company owner - user_name & user_unique_id)

  4. Create a post with all the post details (refer to the document: Likeminds - Client feed Data Migration) and the entity_id of the company widget.

  5. Call the feed/post API (POST) with a new attachment in the attachments array of the request body:

  • attachment_type: 5

  • attachment_meta: { "entity_id" : "<_id from widget response>"}

        curl --location --request POST 'https://auth.likeminds.community/feed/post' \
    --header 'Authorization: <auth token>' \
    --header 'Content-Type: application/json' \
    --data '{
    "text": "New post with company widget",
    "attachments" : [
    { // existing attachments (i.e - img, video, etc)
    "attachment_type": 1, //type: integer
    "attachment_meta" : {
    "name": "name",
    "url" : "url"
    }
    },
    { // company widget attachment
    "attachment_type" : 5, //type: integer
    "attachment_meta" : {
    "entity_id" : "650b35486ce4dc22cf3788e8" // company widget id ("_id")
    }
    }
    ]
    } '

Fetch Widgets

  1. Fetch the widget for a company using the unique identifier.

  2. Call the sdk/initiate API (with user_name and user_unique_id) and retrieve the access_token from the response to generate an auth_token, before calling the mentioned API (or if the auth_token is expired).

  3. Fetch the widget for a specific company using the /widget API (GET) with the following query parameters:

  • search_key="metadata.company_id"

  • search_value="<id of the company>"

    NOTE: The double quotes ("") are mandatory characters in the values for the above parameters.

    curl --location 'https://auth.likeminds.community/widget?search_key=%22metadata.company_id%22&search_value=%22%3Cid%20of%20the%20company%3E%22' \
    --header 'Authorization: <auth_token>'
  1. Confirm that there exists only one widget for a specific company.

Example response for the above API:

{
"success": true,
"data": {
"widgets": [
{
"_id": "65362426068a0ec51a1768cc", // company widget id
"_lm_meta": null,
"created_at": 1698047014476,
"metadata": {
"ccompany_image_url": "image url",
"company_id": "unique_id_1",
"company_name": "company name"
},
"parent_entity_id": "<post id>",
"parent_entity_type": "post",
"updated_at": 1698047014476
}
]
}
}