How to Get Selected user post form its join community

As per our requirements, we are building a profile timeline where we want to show the post user has created in a particular community where user is part of. But we are not able to see any documentation to find this particular list of posts created by user in the community.

Kindly help us, how the above thing can be accomplished. Thanks!

Hello, Anuj

For your specific use case, we recommend exploring the Content Search feature. You can find additional information at the following link: https://docs.amity.co/developers/beta-features/content-search

and here’s an example for you:

Case 1 : User A searches for posts by User A in Community A.

{
    "apiKey": "apiKey",
    "userId": "A",
    "query": {
        "targetType": "community",
        "targetId": [
            "communityId"
        ],
        "postedUserId": "A",
        "text": ""
    }
}

Case 2: User B searches for posts by User A in all public communities.

{
    "apiKey": "apiKey",
    "userId": "B",
    "query": {
        "targetType": "public",
        "publicSearch": "true",
        "postedUserId": "A",
        "text": ""
    }
}

Best regards,

Support Team

@amitysupport i have tried to implement the above solution But i am facing issue in it.

Firstly I have generated the Access-Token form session Api
https://api.sg.amity.co/api/v3/sessions

Then I have call content-Search api by passing the accessToken which i have received from above Api call.

curl --location 'https://beta.amity.services/search/posts' \
--header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
    "apiKey": "YOUR_API_KEY",
    "userId": "YOUR_USER_ID",
    "query": {
        "targetType": "community",
        "targetId": [
            "TARGET_COMMUNITY_ID"
        ],
        "postedUserId": "POSTED_USER_ID",
        "text": ""
    }
}'

But have receiving 500 Internal Server Error.

What should i should do?

For your use case , We recommend that you use https://beta.amity.services/search/v2/posts instead.

Best regards,

Support Team

@amitysupport I have tried to this url but still i am getting this 500 Internal Error. Could u please list me what can be cause of this? i am passing same request body and header to this url.

Your request seems correct. However, we have noticed that you have not yet requested to enable the Content Search feature. Our support team will contact you via email to assist further.

Best regards,

Support Team

Hi @amitysupport I have contacted with support team i got the reply of successfully enable the content search but now i am getting the Json response with Feature is not enabled

Request body

curl --location 'https://beta.amity.services/search/v2/posts' \
--header 'Authorization: Bearer ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
    "apiKey": "API_KEY",
    "userId": "USER_ID",
    "query": {
        "targetType": "community",
        "targetId": [
            "COMMUNITY_ID"
        ],
        "postedUserId": "POSTED_USER_ID",
        "text": ""
    }
}'

Response Body

{
    "success": false,
    "message": "Feature is not enabled"
}

Hello, could you kindly provide the full cURL command, along with the user ID, in your existing email correspondence with our support team? Our team will assist in verifying this issue. Thank you.