This method allows you to edit previously sent text messages. The feature is particularly useful when you need to correct errors or update information in a sent message without having to send a new one.
Supported Messengers
The message editing API method is available for the following messengers: Telegram Personal, Telegram Bot.
Request Example:
GET https://wamm.chat/api2/msg_edit/{token}/{msg_id}?text={text} or
GET https://wamm.chat/api2/msg_edit/{token}/{msg_id}/{text} Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| token | string | Yes | API token obtained from settings |
| msg_id | integer | Yes | ID of the message to be edited |
| text | string | Yes | New message text up to 4500 characters in UTF-8 encoding, encoded with the urlencode function. To insert a line break, use "%0A" in the text. The parameter can be passed via GET or POST. |
Success Response
{"err":0,"result":"success"} Possible Errors
| Error Code | Description |
|---|---|
| token fail | Token error |
| acc not authorized | Connection not authorized |
| Channel type is not support this method | Channel does not support message editing |
| text fail | Empty text |
| text fail, more 4500 | Text is too large, exceeds 4500 characters |
Usage Examples
curl -X GET "https://wamm.chat/api2/msg_edit/YOUR_TOKEN/1234567/?text=Updated%20message"
function editMessage($token, $msgId, $newText) {
// Prepare the request URL
$url = "https://wamm.chat/api2/msg_edit/$token/$msgId/?text=" . urlencode($newText);
// Execute the request
$response = file_get_contents($url);
// Process the response
if ($response !== false) {
// Convert the response to an array
$json_response = json_decode($response, true);
// Check for errors
if (isset($json_response['err'])) {
if ($json_response['err'] == 0 && isset($json_response['result']) && $json_response['result'] == 'success') {
echo "Message updated successfully";
} else {
echo "Error: " . $json_response['err'];
}
} else {
echo "Failed to process server response";
}
} else {
echo "Failed to execute request to server";
}
}
// Use the function to edit a message
$token = "YOUR_TOKEN";
$msgId = 1234567;
$newText = "Updated message";
editMessage($token, $msgId, $newText);