mwstake / mediawiki-component-commonwebapis
提供各种Web API(操作API和REST API)
2.0.26
2024-09-06 05:52 UTC
Requires
Requires (Dev)
- mediawiki/mediawiki-codesniffer: 39.0.0
- mediawiki/minus-x: 1.1.1
- php-parallel-lint/php-console-highlighter: 1.0.0
- php-parallel-lint/php-parallel-lint: 1.3.2
- phpunit/phpunit: ^8.5
- dev-master
- 2.0.26
- 2.0.25
- 2.0.24
- 2.0.23
- 2.0.22
- 2.0.21
- 2.0.20
- 2.0.19
- 2.0.18
- 2.0.17
- 2.0.16
- 2.0.15
- 2.0.14
- 2.0.13
- 2.0.12
- 2.0.11
- 2.0.10
- 2.0.9
- 2.0.8
- 2.0.7
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.0.x-dev
- 1.0.27
- 1.0.26
- 1.0.25
- 1.0.24
- 1.0.23
- 1.0.22
- 1.0.21
- 1.0.20
- 1.0.19
- 1.0.18
- 1.0.17
- 1.0.16
- 1.0.15
- 1.0.14
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-ERM38415
- dev-FixFileQueryMajor
- dev-category-store
- dev-AddTitleIsRedirect
- dev-user_query_bug_fix
- dev-FixBatch
- dev-title_tree
- dev-T336567
This package is auto-updated.
Last update: 2024-09-06 05:53:08 UTC
README
MediaWiki通用Web API
提供各种Web API(操作API和REST)。
此代码旨在在MediaWiki应用环境中执行。不打算独立使用。
兼容性
2.0.x-> MediaWiki 1.391.0.x-> MediaWiki 1.35
先决条件
在MediaWiki扩展中使用
在您的扩展的composer.json中需要此组件
{
"require": {
"mwstake/mediawiki-component-commonwebapis": "~2"
}
}
获取可用端点
$endpoints = MediaWikiServices::getInstance()->getService( 'MWStakeCommonWebAPIs' )->getAvailableEndpoints();
将返回所有已注册端点及其REST路径配置的列表
客户端抽象
为了更容易地从JS访问这些端点,实现了抽象。
要启用它,请加载RL模块ext.mws.commonwebapis并按以下方式使用
mw.loader.using( 'ext.mws.commonwebapis' ).then( function () { mws.commonwebapi.user.query( { query: 'MyUser' } ); } );
REST API
过滤
为了指定过滤器,您可以使用filter参数。它是一个JSON编码的对象数组。每个对象具有以下属性
property- 要过滤的字段value- 要过滤的值operator- 用于过滤器的运算符。可能的值包括eq(等于)、neq(不等于)、lt(小于)、lte(小于等于)、gt(大于)、gte(大于等于)、like(类似)、nlike(不类似)、in(在)、nin(不在)、isnull(为空)、isnotnull(非空)、between(之间)、nbetween(不在之间)、ilike(不区分大小写的类似)、nilike(不区分大小写的不同)、regexp(正则表达式)、nregexp(非正则表达式)。根据过滤器的类型,某些运算符可能不可用。type- 值的类型。可能的值包括string(字符串)、integer(整数)、float(浮点数)、boolean(布尔值)、list(列表)
排序
为了指定排序,您可以使用sort参数。它是一个JSON编码的对象数组。每个对象具有以下属性
property- 要排序的字段direction- 排序方向。可能的值包括asc(升序)和desc(降序)
示例
mw.loader.using( 'ext.mws.commonwebapis' ).then( function () { mws.commonwebapi.user.query( { filter: JSON.stringify( [ { field: 'user_name', value: 'MyUser', operator: 'eq', type: 'string' } ] ), sort: JSON.stringify( [ { field: 'user_name', direction: 'asc' } ] ) } ); } );