Messaging API

Messaging API

core_message_get_messages

This function retrieves messages for a user. You can get all messages sent to a user, or get the conversation between two specific users.

Let's review the POST parameters for this function:

  1. Parameters:
    • useridto= int (Required: The numeric ID of the user who received the messages.)
    • useridfrom= int (Optional: The numeric ID of the user who sent the messages. Defaults to 0, meaning 'from any user'.)
  2. Important Rule:
    • You must provide a specific user ID for at least one of the parameters. Setting both useridto and useridfrom to 0 is not permitted.

cURL Command Example 1 (Get all messages sent TO a user):

curl "https://courses.yoursite.com/webservice/rest/server.php?wstoken=XXXXXXXXXXXXXXX" \
-d "wsfunction=core_message_get_messages" \
-d "useridto=123" \
-d "useridfrom=0"

cURL Command Example 2 (Get a conversation BETWEEN two users):

curl "https://courses.yoursite.com/webservice/rest/server.php?wstoken=XXXXXXXXXXXXXXX" \
-d "wsfunction=core_message_get_messages" \
-d "useridto=123" \
-d "useridfrom=456"
    • Related Articles

    • Grades API

      gradereport_overview_get_course_grades This function retrieves an overview of all final course grades for a specific user. Let's review the POST parameters for this function: Optional Parameter: userid= int (Optional: The numeric ID of the user. If ...
    • User API

      core_user_create_users We advise the use of a developer to help you setup your API connection. This example shows how to create new users. Let's review the POST parameters for this function: Required Parameters: users[0][username]= string (Required: ...
    • Generate your API Key

      Step 1: Click on "Site admin" > "Integrations" > "Manage tokens": Step 2: Click on "Create Token": Step 3: (1) Select the user you wish to give the API Token to, (2) Select "API" then (3) Save: Step 4: Share this token with the user or save it if ...
    • Setting Up Your API

      We advise the use of a developer to help you setup your API connection. We will offer an example of how to CREATE A NEW USER on your LMS using a cURL command. Let's review the required POST parameters for the core_user_create_users function: ...
    • SCORM API

      mod_scorm_get_scorm_user_data This function retrieves detailed user tracking data for a specific attempt on a SCORM package. Let's review the POST parameters for this function: Required Parameters: scormid= int (Required: The numeric instance ID of ...