• Hello,

    We are trying to use the api, to send messages from an external app, not developed with wordpress.

    /wp-json/buddypress/v1/messages/

    We send the authentication token, but when it tries to create the new message it throws this error:

    {
        "code": "bp_rest_messages_create_failed",
        "message": "There was an error trying to create the message.",
        "data": {
            "status": 500
        }
    

    Reviewing your code we see that it uses this function that validates if the user is logged in : bp_loggedin_user_id

    Can this endpoint (/wp-json/buddypress/v1/messages/ ) be used by a valid user who is not logged in?

    Is there any way to extend this endpoint to be used from an app not developed with wordpress ?

    • This topic was modified 2 years, 1 month ago by dbayon24.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author wordplus

    (@wordplus)

    Hi there!

    I would recommend you to create custom API endpoint (or even simple PHP endpoint) for your purpose.

    And just use this function to send message:

    $args = array(
            'sender_id'  => 1,
            'thread_id'  => false,
            'recipients' => $user_id,
            'subject'    => 'Welcome to WordPlus.org',
            'content'    => "<strong>Welcome to WordPlus.org</strong>\n\n If you have any question about <strong>BP Better Messages</strong> you can ask it here directly.",
            'date_sent'  => bp_core_current_time()
        );
    
        $result = BP_Better_Messages()->functions->new_message( $args );

    With this you are fully free with authentication process and other things.

    Thanks!

    Thread Starter dbayon24

    (@dbayon24)

    Thank you!

    We have bought the license to use websocket in our chat, is it possible to use websocket for our external app too?

    Plugin Author wordplus

    (@wordplus)

    Hi there!

    The plugin is possible to use only with the provided UX, which is based on HTML/CSS/JS. You can run the plugin in your app in you can embed webview with plugin page from your website.

    Integrating to 3rd party interface is complicated to implement.

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘extend the API for sending private messages’ is closed to new replies.