API:ClearHasMsg

From mediawiki.org
This page is a translated version of the page API:ClearHasMsg and the translation is 100% complete.

Solicitud GET que limpia el indicador hasmsg del usuario actual.

Versión de MediaWiki:
1.24

Documentación de la API


action=clearhasmsg

(main | clearhasmsg)
  • This module requires read rights.
  • This module requires write rights.
  • This module only accepts POST requests.
  • Source: MediaWiki
  • License: GPL-2.0-or-later

Clears the hasmsg flag for the current user.

Example:
Clear the hasmsg flag for the current user.
api.php?action=clearhasmsg [open in sandbox]

Ejemplo

Solicitud POST

Borrar el indicador hasmsg del usuario actual.


Respuesta

{
    "clearhasmsg": "success"
}

Código de muestra

Python

#!/usr/bin/python3

"""
    clear_has_msg.py

    MediaWiki API Demos
    Demo of `ClearHasMsg` module: Clear the hasmsg flag for the current user.

    MIT License
"""

import requests

S = requests.Session()

URL = "https://en.wikipedia.org/w/api.php"

PARAMS = {
    "action": "clearhasmsg",
    "format": "json"
}

R = S.post(url=URL, data=PARAMS)
DATA = R.json()

print(DATA)

PHP

<?php

/*
    clear_has_msg.php

    MediaWiki API Demos
    Demo of `ClearHasMsg` module: Clear the hasmsg flag for the current user.

    MIT License
*/

$endPoint = "https://en.wikipedia.org/w/api.php";
$params = [
    "action" => "clearhasmsg",
    "format" => "json"
];

$ch = curl_init();

curl_setopt( $ch, CURLOPT_URL, $endPoint );
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_POSTFIELDS, http_build_query( $params ) );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_COOKIEJAR, "cookie.txt" );
curl_setopt( $ch, CURLOPT_COOKIEFILE, "cookie.txt" );

$response = curl_exec($ch);
curl_close($ch);

echo ($response);

JavaScript

/*
	clear_has_msg.js

    MediaWiki API Demos
    Demo of `ClearHasMsg` module: Clear the hasmsg flag for the current user.

    MIT License
*/

var url = "https://en.wikipedia.org/w/api.php"; 

var params = {
    action: "clearhasmsg",
    format: "json"
};
request.post({ url: url, form: params }, function(error, res, body) {
    if (error) {
        return;
    }
    console.log(body);
});

MediaWiki JS

/*
	clear_has_msg.js

    MediaWiki API Demos
    Demo of `ClearHasMsg` module: Clear the hasmsg flag for the current user.

    MIT License
*/

var params = {
    action: "clearhasmsg",
    format: "json"
},
api = new mw.Api();

api.post( params ).done( function ( data ) {
console.log( data );
} );

Posibles errores

Código Información
mustbeposted El módulo clearhasmsg requiere una petición POST.

Notas adicionales

  • La acción clearhasmsg eliminará el indicador HasMsg, que hace que el mensaje

Tienes mensajes nuevos aparezca y devuelve verdadero en la consulta HasMsg. Puede ser utilizado por aplicaciones que recuperan la página de discusión utilizando el API, que a diferencia de abrir tu página de discusión en un navegador, no elimina automáticamente este indicador.

  • Cuando activas esta acción, el banner Tiene mensajes nuevos no aparecerá hasta que recibas más mensajes de otros usuarios.
  • Este módulo debe recibir una solicitud POST desde la versión 1.29-wmf.5.[1]

Referencias

  1. [$CAMBIO de RUPTURA del correo: action=clearhasmsg requerirá CORREO] en la Lista de correo mediawiki-api-announce