API:Emailuser/ja: Difference between revisions
Appearance
Content deleted Content added
update |
Updating to match new version of source page |
||
| (48 intermediate revisions by 6 users not shown) | |||
| Line 1: | Line 1: | ||
<languages/> |
|||
{{API}} |
{{API}} |
||
{{API-head |
{{API-head |
||
| Line 9: | Line 9: | ||
}} |
}} |
||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
| ⚫ | |||
== API documentation == |
|||
</div> |
|||
{{Api help|emailuser|frame=yes}} |
|||
<span id="Token"></span> |
|||
メールを送信するにはトークンが必要です。このトークンは編集のためのトークンと同一のもので、送信先に関わらず同じですが、ログインの度に変わります。電子メールトークンは [[API:Tokens/ja|action=tokens]] で type=email を指定する(MW 1.20+), または以下の方法で取得できます: |
|||
| ⚫ | |||
メールを送信するには、メール トークンが必要です。 |
|||
このトークンは、編集トークンと同じで、全受信者に共通ですが、ログインの度に変更されます。 |
|||
メールトークンは、{{ll|API:Tokens|action{{=}}query&meta{{=}}tokens}}で入手できるほか、以下のやり方でも入手できます : |
|||
{{ApiEx |
{{ApiEx |
||
|desc=メール トークンの取得 |
|||
|desc=Obtaining an email token |
|||
|p1=action=query |
|p1=action=query |
||
|p2=meta=tokens |
|p2=meta=tokens |
||
|result=< |
|result=<syntaxhighlight lang="json">{ |
||
"batchcomplete": "", |
"batchcomplete": "", |
||
"query": { |
"query": { |
||
| Line 24: | Line 31: | ||
} |
} |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
}} |
}} |
||
{{anchor|Sending e-mail to users}} |
{{anchor|Sending e-mail to users}} |
||
<span id="Sending_email_to_users"></span> |
|||
== 利用者へのメールの送信 == |
== 利用者へのメールの送信 == |
||
メールアドレスを認証した利用者に action=emailuser でメールを送信 |
メール アドレスを認証した利用者に action=emailuser でメールを送信できます。 |
||
メールの送信には[[Special:MyLanguage/Manual:$wgRateLimits|制限]]があります。 |
|||
<span id="Parameters"></span> |
|||
=== パラメーター === |
=== パラメーター === |
||
* |
*{{ApiParam|target|2=メールの宛先の利用者|required=1}} |
||
* |
*{{ApiParam|subject|2=メッセージの件名}} |
||
* |
*{{ApiParam|text|2=メッセージ|required=1}} |
||
* |
*{{ApiParam|token|2=以前のリクエストで取得したトークン。 必ず <code>+</code> を <code>%2B</code> にエンコードしてください。|required=1}} |
||
* |
*{{ApiParam|ccme|2=設定すると、メールのコピーをあなたにお送りします}} |
||
<span id="Examples"></span> |
|||
=== 例 === |
=== 例 === |
||
| ⚫ | |||
| ⚫ | |||
{{ApiEx |
{{ApiEx |
||
|desc= |
|desc=[[User:Catrope]]へメールを送信します |
||
|p1=action=emailuser |
|p1=action=emailuser |
||
|p2=target=Catrope |
|p2=target=Catrope |
||
| Line 49: | Line 59: | ||
|p4=text=Just%20wanted%20to%20say%20hi |
|p4=text=Just%20wanted%20to%20say%20hi |
||
|p5=token=58b54e0bab4a1d3fd3f7653af38e75cb+\ |
|p5=token=58b54e0bab4a1d3fd3f7653af38e75cb+\ |
||
|result=< |
|result=<syntaxhighlight lang="json">{ |
||
"emailuser": { |
|||
<api> |
|||
"result": "Success" |
|||
} |
|||
</api></source>}} |
|||
}</syntaxhighlight>}} |
|||
<span id="Sample_code"></span> |
|||
=== サンプル コード === |
|||
<!-- Transclude Sample code --> |
|||
<div style="overflow-y:hidden"> |
|||
{{:{{translatable}}/Sample code 1}} |
|||
</div> |
|||
<span id="Possible_errors"></span> |
|||
=== 起こりうるエラー === |
=== 起こりうるエラー === |
||
{{ll|API:Errors#Standard error messages|通常のもの}}に加え : |
|||
In addition to the [[API:Errors/ja#標準的なエラーメッセージ|usual stuff]]: |
|||
{| class="wikitable sortable" |
{| class="wikitable sortable" |
||
! |
! コード !! 情報 |
||
|- |
|- |
||
| cantsend || {{int|apierror-cantsend}} |
| cantsend || {{int|apierror-cantsend}} |
||
| Line 65: | Line 84: | ||
| blockedfrommail || {{int|apierror-blockedfrommail}} |
| blockedfrommail || {{int|apierror-blockedfrommail}} |
||
|- |
|- |
||
| usermaildisabled || |
| usermaildisabled || メール機能が無効になっています |
||
|- |
|- |
||
| notarget || {{int|apierror-notarget}} |
| notarget || {{int|apierror-notarget}} |
||
|- |
|- |
||
| noemail |
| noemail|| {{int|noemailtext}} |
||
|- |
|||
| nowikiemail|| {{int|nowikiemailtext}} |
|||
|} |
|} |
||
<span id="Checking_emailable_status"></span> |
|||
== 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: |
|||
メールの送信を試みる前に、まずその利用者がメール可能であるか確認することを推奨します。 |
|||
これを行うには、その利用者について(あるいは何人かの利用者について一度に)リストクエリを実行してください。こちらはAjaxを使用する例です: |
|||
<syntaxhighlight lang="JavaScript"> |
<syntaxhighlight lang="JavaScript"> |
||
new mw.Api().get( { |
new mw.Api().get( { |
||
| Line 86: | Line 110: | ||
</syntaxhighlight> |
</syntaxhighlight> |
||
クライアントサイドスクリプトからテストしている場合は、単純にt-emailuserリスト項目の存在を確認することもできます: |
|||
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: |
|||
<syntaxhighlight lang="JavaScript"> |
<syntaxhighlight lang="JavaScript"> |
||
emailable = $( '#t-emailuser' ).length ? true : false; |
emailable = $( '#t-emailuser' ).length ? true : false; |
||
Latest revision as of 02:55, 5 April 2026
| このページは MediaWiki 操作 API の説明文書の一部です。 |
| Emailuser | ||
|---|---|---|
| Email a user. このモジュールは generator としては使用できません。 | ||
| 接頭辞 | なし | |
| 必要な権限 | sendemail | |
| POST のみ? | はい | |
| 自動生成ヘルプ | 現行バージョン | |
| 追加されたバージョン |
| |
API documentation
トークン
メールを送信するには、メール トークンが必要です。 このトークンは、編集トークンと同じで、全受信者に共通ですが、ログインの度に変更されます。 メールトークンは、action=query&meta=tokensで入手できるほか、以下のやり方でも入手できます :
メール トークンの取得
| 結果 |
|---|
{
"batchcomplete": "",
"query": {
"tokens": {
"csrftoken": "7773cbfff263682c97ffc74b8672cbf25a5e0045+\\"
}
}
}
|
利用者へのメールの送信
メール アドレスを認証した利用者に action=emailuser でメールを送信できます。 メールの送信には制限があります。
パラメーター
target: メールの宛先の利用者subject: メッセージの件名text: メッセージtoken: 以前のリクエストで取得したトークン。 必ず+を%2Bにエンコードしてください。ccme: 設定すると、メールのコピーをあなたにお送りします
例
簡潔性のためにこの例ではすべてのパラメーターをGETリクエストで渡していますが、 action=emailuser はPOSTリクエストを必要とします; GETリクエストだとエラーが発生します。
User:Catropeへメールを送信します
api.php? action=emailuser& target=Catrope& subject=Hi& text=Just%20wanted%20to%20say%20hi& token=58b54e0bab4a1d3fd3f7653af38e75cb+\ [ApiSandbox で試用する]
| 結果 |
|---|
{
"emailuser": {
"result": "Success"
}
}
|
サンプル コード
起こりうるエラー
通常のものに加え :
| コード | 情報 |
|---|---|
| cantsend | You are not logged in, you do not have a confirmed email address, or you are not allowed to send email to other users, so you cannot send email. |
| blockedfrommail | You have been blocked from sending email. |
| usermaildisabled | メール機能が無効になっています |
| notarget | ⧼apierror-notarget⧽ |
| noemail | この利用者は有効なメールアドレスを登録していません。 |
| nowikiemail | この利用者は他の利用者からメールを受け取らない設定にしています。 |
メール状態の確認
メールの送信を試みる前に、まずその利用者がメール可能であるか確認することを推奨します。 これを行うには、その利用者について(あるいは何人かの利用者について一度に)リストクエリを実行してください。こちらは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' );
} );
クライアントサイドスクリプトからテストしている場合は、単純にt-emailuserリスト項目の存在を確認することもできます:
emailable = $( '#t-emailuser' ).length ? true : false;
| 以下の説明文書は、このサイト (MediaWiki.org) で稼働しているリリース前のバージョンのMediaWikiによって自動的に生成された、Special: |
action=emailuser
(main | 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.
Specific parameters:
Other general parameters are available.
- 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.
Example:
- Send an email to the user WikiSysop with the text Content.
- api.php?action=emailuser&target=WikiSysop&text=Content&token=123ABC [open in sandbox]