API:Emailuser/pl
Ta strona jest częścią dokumentacji API akcji MediaWiki. |
Emailuser | ||
---|---|---|
Email a user. Ten moduł nie może być użyty jako generator. | ||
Prefiks | brak | |
Wymagane uprawnienia | sendemail | |
Tylko POST? | Tak | |
Wygenerowana pomoc | Aktualna | |
Dodane w wersji |
|
Token
To send an email, an email token is required. This token is equal to the edit token and the same for all recipients, but changes at every login. Email tokens can be obtained via action=query&meta=tokens , or by using the following method:
Obtaining an email token
Wynik |
---|
{
"batchcomplete": "",
"query": {
"tokens": {
"csrftoken": "7773cbfff263682c97ffc74b8672cbf25a5e0045+\\"
}
}
}
|
Sending email to users
You can send email to users who have a confirmed email address with action=emailuser. Sending email is subject to rate limits.
Parametry
target
: User to send email tosubject
: The subject of the messagetext
: The messagetoken
: The token obtained in the previous request. Take care to encode the+
as%2B
ccme
: If set, a copy of the email will be sent to you
Przykłady
Sending an email to User:Catrope
Wynik |
---|
<?xml version="1.0" encoding="utf-8"?>
<api>
<emailuser result="Success" />
</api>
|
Przykładowy kod
Możliwe błędy
In addition to the usual stuff :
Code | Info |
---|---|
cantsend | Nie jesteś zalogowany, nie masz potwierdzonego adresu e-mail, albo nie masz prawa wysyłać e-maili do innych użytkowników, więc nie możesz wysłać wiadomości e-mail. |
blockedfrommail | Została Ci zablokowana możliwość wysyłania e-maili. |
usermaildisabled | User email has been disabled |
notarget | You have not specified a valid target for this action. |
noemail | Ten użytkownik nie podał poprawnego adresu e‐mail. Ten użytkownik nie chce otrzymywać wiadomości e‐mail od innych użytkowników. |
Checking emailable status
Before trying to send an email, it is recommended to check if the user is emailable first. To do this, you can execute a list query on the user (or several users at once). Here is an example using Ajax:
new mw.Api().get( {
action: 'query',
list: 'users',
ususers: mw.config.get( 'wgTitle' ),
usprop: 'emailable',
rawcontinue: ''
} ).done( function( getEmailable ) {
alert( ( getEmailable.query.users[ 0 ][ 'emailable' ] !== undefined ) ? 'emailable' : 'not emailable' );
} );
If you are testing from a client-side script, it is also possible to simply check for the existence of the t-emailuser list item:
emailable = $( '#t-emailuser' ).length ? true : false;
Poniższa dokumentacja jest rezultatem Special: |
action=emailuser
- This module requires read rights.
- This module requires write rights.
- This module only accepts POST requests.
- Source: MediaWiki
- License: GPL-2.0-or-later
Email a user.
- target
User to send the email to.
- This parameter is required.
- subject
Subject header.
- This parameter is required.
- text
Email body.
- This parameter is required.
- ccme
Send a copy of this mail to me.
- Type: boolean (details)
- token
A "csrf" token retrieved from action=query&meta=tokens
- This parameter is required.
- Send an email to the user WikiSysop with the text Content.
- api.php?action=emailuser&target=WikiSysop&text=Content&token=123ABC [open in sandbox]