hpa是什么意思| 未曾谋面什么意思| 萨洛蒙什么档次| 波推飞机什么意思| 工作坊是什么意思| 十二生肖排第一是什么生肖| 违反禁令标志指示什么意思| 伴手礼是什么| 龙凤胎是什么意思| 肺炎后遗症有什么症状| 用加一笔是什么字| 手指关节肿大是什么原因| 袁隆平是什么家| mmhg是什么意思| 簇新是什么意思| 隐形眼镜半年抛是什么意思| 小腿抽筋是什么原因| 岳飞属什么生肖| 放浪形骸是什么意思| 盆腔镜检查是查什么的| 乳糖是什么糖| s是什么牌子| 元帅是什么生肖| 美人尖是什么| 漂洗是什么意思| 肌醇是什么| 29度穿什么衣服合适| 体现是什么意思| 黄芪什么人不能吃| 感冒吃什么恢复快| 乌托邦是什么| 虫草泡水喝有什么功效| 蜻蜓是什么生肖| 转是什么意思| 负心汉是什么意思| apm是什么品牌| 尿素氮高吃什么药| 什么是备孕| 减肥吃什么坚果| 探病买什么水果| 礼仪是什么| 心衰吃什么药效果最好| 外油内干是什么肤质| 换床有什么讲究| 淋球菌是什么病| 什么牌子的助听器最好| 野生型是什么意思| 乳腺增生的前兆是什么| 体积是什么意思| 肾衰竭有什么症状| tpa是什么意思| 7月15日是什么日子| 孩子睡觉出汗多是什么原因| 骨密度z值是什么意思| 预防脑梗用什么药效果好| 营养神经吃什么药效果好| 拉肚子吃什么药管用| 中分化是什么意思| 儿童办理身份证需要什么材料| 敕令是什么意思| 夜宵吃什么好| 何方珠宝是什么档次| 6月8日什么星座| 99年属兔的是什么命| 红糖是什么做的| 桃子不能和什么一起吃| 蛇属什么五行| 火箭军是干什么的| 免疫系统由什么组成| 加德纳菌阳性是什么意思| 火车为什么会晚点| 晚上睡觉腿抽筋是什么原因| 栅栏是什么意思| 气滞血瘀吃什么药| 双月刊什么意思| 月经后是什么期| rush是什么意思| 婴儿八个月可以吃什么辅食| 荨麻疹吃什么药好的快| 路由器坏了有什么症状| 乳房有硬块是什么原因| 脾的主要功能是什么| 自限性疾病是什么意思| 家里养什么宠物好| 水鸭跟什么煲汤最佳| 脂肪肝什么东西不能吃| 儿童热感冒吃什么药| 树叶像什么比喻句| 覅是什么意思| 两胸之间是什么部位| 拒服兵役是什么意思| 避孕药吃了有什么副作用| 移车打什么电话| 什么牌子的洗面奶好用| 弦是什么| 灬是什么意思| 随诊复查是什么意思| 72年鼠是什么命| 自律是什么意思| 冲蛇煞西是什么意思| 裸贷是什么意思| 走路不稳是什么原因| 围绝经期是什么意思| 领盒饭是什么意思| 吃坏肚子了吃什么药| 什么胃病需要做手术| 粉玫瑰适合送什么人| 四方草地是什么生肖| 脂肪肝轻度是什么意思| 更年期提前是什么症状| island什么意思| 还俗是什么意思| 冬瓜有什么功效和作用| 教师节应该送老师什么花| 息肉吃什么药可以消掉| 臣字五行属什么| 维酶素片搭配什么药治萎缩性胃炎| 吃什么对眼睛好| 脸麻是什么原因引起的| 三月七号是什么星座| 孕妇零食可以吃什么| 立秋是什么时候| 低氧血症是什么意思| 膝盖里面痛什么原因引起的| 松石绿是什么颜色| 啤酒花是什么东西| 大是大非是什么意思| 麦的部首是什么| 233是什么意思啊| 吃醋对身体有什么好处| 苹果有什么功效和营养| 议论纷纷是什么意思| 熟褐色是什么颜色| 什么牌子奶粉最好| 退职是什么意思| 腰疼肚子疼是什么原因引起的| 小孩脱水有什么症状| 宝宝吐奶是什么原因| 羊内腰和外腰分别是什么| 儿童乐园有什么好玩的| 血管痉挛是什么原因引起的| 农村养殖什么好| 梦到好多蛇是什么意思| 可逆是什么意思| 缠足是什么时候开始的| 马上风为什么拔不出来| pr间期延长是什么意思| 麻婆豆腐用什么豆腐| 风疟病是什么意思| 1989年属蛇是什么命| 愚公移山是什么意思| 桔梗是什么| psc是什么病| 手足口病有什么症状| 皮肤起水泡发痒是什么病| 10月21是什么星座| 鱼香肉丝用什么肉做| 湿疹为什么一热就出来| 石千读什么| 狗狗可以吃什么水果| 木石是什么字| 黄标车是什么意思| 左肺钙化灶是什么意思| 血痰是什么原因| 乙肝抗体阴性是什么意思| 异卵双胞胎是什么意思| 小孩肚子痛挂什么科| 吃什么可以补黑色素| 小狗感冒吃什么药| chanel是什么牌子| 看甲状腺挂什么科| 九月28号是什么星座| 改户口需要什么手续| 贫血喝什么茶| 宫保鸡丁属于什么菜系| 突然肚子疼是什么原因| 黄金桂是什么茶| 下联是什么| 腿老是抽筋是什么原因| 脾是干什么用的| 为什么喝水血糖也会高| 头晕没精神是什么原因| 626是什么日子| 土克什么| 八月一日是什么日子| 工事是什么意思| 樱花什么时候开花| 灵犀是什么意思| 咬到舌头是什么预兆| 林彪什么时候死的| ab是什么| 四两棉花歇后语是什么| 红茶是什么茶| 发烧打什么针| 芥末为什么会冲鼻| 走马观花的走是什么意思| 为什么医院开的钙都是碳酸钙| 痰中带血吃什么药| 吃什么水果对肾好| 乙酰氨基酚是什么药| 轮状胎盘是什么意思| 听诊器能听出什么| 坦诚相待下一句是什么| 什么减肥最好最快| 相位是什么意思| 黄金糕是什么做的| 豌豆是什么豆| 老烂腿用什么药最好| 尿酸高是什么原因引起的| 恶趣味什么意思| 日语为什么| 平的反义词是什么| kb是什么意思| 莼菜是什么菜| g什么意思| 血沉高是什么病| 日加一笔可以变成什么字| 费玉清为什么不结婚| 总打哈欠是什么原因| 四风指什么| 锁骨是什么骨| 杏仁有什么作用和功效| 02属什么| 六月飞雪是什么意思| 女孩名字带什么字好听| 有什么中药可以壮阳| 四平八稳是什么生肖| 鸡胸是什么原因引起的| 胃有问题挂什么科| 西施长什么样| 恋爱是什么| 铁面无私是什么生肖| 侍中是什么官| 什么咖啡好喝| rm是什么位置| 什么两难| 甲状腺球蛋白抗体高是什么意思| ot是什么| 光敏反应是什么意思| 睡眠不好用什么泡脚助于睡眠| 铁公鸡是什么意思| 肾蕨是什么植物| 2019年什么生肖| 咳嗽什么东西不能吃| 龙井茶属于什么茶| paris什么牌子| 芈姝结局是什么| a型血与o型血生的孩子是什么血型| 牛鬼蛇神指什么生肖| 为什么近视不可逆| 晚上吃什么菜| ca医学代表什么意思| 相思成疾是什么意思| 1970年属狗的是什么命| 12月16号是什么星座| 耳朵发烫是什么原因| 内心孤独的人缺少什么| 鹅蛋有什么功效| 眼睛红吃什么药| 青玉是什么玉| 减肥期间适合喝什么酒| 藏青色t恤配什么颜色裤子| 武汉属于什么地区| 活着的意义是什么| 百度Jump to content

雁城新添“羽翼” 衡阳南岳机场将增7条航线

From mediawiki.org
百度 ▲图片来源:视觉中国  根据国家统计局数据显示,2017年我国人均居住消费支出较2016年增长%,占人均消费支出的比重为%;2018年2月居住类居民消费价格指数同比增长%。

This document covers creating an API module in an extension for use with MediaWiki 1.30 and later.

Module creation and registration

[edit]

All API modules are subclasses of ApiBase , but some types of modules use a derived base class. The method of registration also depends on the module type.

action modules
Modules that provide a value for the main action parameter should subclass ApiBase . They should be registered in extension.json using the APIModules key.
format modules
Modules that provide a value for the main format parameter should subclass ApiFormatBase. They should be registered in extension.json using the APIFormatModules key. It's very uncommon for an extension to need to add a format module.
query submodules
Modules that provide a value for the prop, list, or meta parameters to action=query should subclass ApiQueryBase (if not usable as a generator) or ApiQueryGeneratorBase (if usable as a generator). They should be registered in extension.json using the APIPropModules, APIListModules, or APIMetaModules key.

In all cases, the value for the registration key is an object with the module name (i.e. the value for the parameter) as the key and the class name as the value. Modules may also be registered conditionally using the ApiMain::moduleManager (for action and format modules) and ApiQuery::moduleManager (for query submodules) hooks.

Implementation

[edit]

Prefix

[edit]

In the constructor of your API module, when you call parent::__construct() you can specify an optional prefix for your module's parameters. (In the generated documentation for a module this prefix, if any, appears in parentheses in the heading for the module.) If your module is a query submodule then a prefix is required, since a client can invoke multiple submodules each with its own parameters in a single request. For action and format modules, the prefix is optional.

Parameters

[edit]

Most modules require parameters. These are defined by implementing getAllowedParams(). The return value is an associative array where keys are the (unprefixed) parameter names and values are either the scalar default value for the parameter or an array defining the properties of the parameter using the PARAM_* constants defined by ApiBase.

The example illustrates the syntax and some of the more common PARAM_* constants.

	protected function getAllowedParams() {
		return [
			// An optional parameter with a default value
			'simple' => 'value',

			// A required parameter
			'required' => [
				ApiBase::PARAM_TYPE => 'string',
				ApiBase::PARAM_REQUIRED => true,
			],

			// A parameter accepting multiple values from a list
			'variable' => [
				// The default set of values
				ApiBase::PARAM_DFLT => 'foo|bar|baz',
				// All possible values
				ApiBase::PARAM_TYPE => [ 'foo', 'bar', 'baz', 'quux', 'fred', 'blah' ],
				// Indicate that multiple values are accepted
				ApiBase::PARAM_ISMULTI => true,
				// Use standard "per value" documentation messages
				ApiBase::PARAM_HELP_MSG_PER_VALUE => [],
			],

			// A standard "limit" parameter. It's generally best not to vary from this standard.
			'limit' => [
				ApiBase::PARAM_DFLT => 10,
				ApiBase::PARAM_TYPE => 'limit',
				ApiBase::PARAM_MIN => 1,
				ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
				ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2,
			],
		];
	}

Parameters are documented using MediaWiki's i18n mechanism. See #Documentation for details.

Execution and output

[edit]

The code actually implementing the module goes in the execute() method. This code will generally use $this→extractRequestParams() to get the input parameters, and will use $this→getResult() to get the ApiResult object to add any output to.

Query prop submodules should use $this→getPageSet() to access the set of pages to operate on.

Query submodules that can be used as generators will also need to implement executeGenerator() which is passed and ApiPageSet that should be filled with the generated pages. In this case, the ApiResult should generally not be used.

Caching

[edit]

By default API responses are marked as not cacheable ('Cache-Control: private')! For action modules, you can allow caching by calling $this→getMain()→setCacheMode(). This still requires clients pass the maxage or smaxage parameters to actually enable caching. You can force caching by also calling $this→getMain()→setCacheMaxAge().

For query modules, do not call those methods. You can allow caching by instead implementing getCacheMode().

In either case, be sure that private data is not exposed.

Token handling

[edit]

If your action module changes the wiki in any way, it should require a token of some kind. To have this handled automatically, implement the needsToken() method, returning the token that your module requires (probably the 'csrf' edit token). The API base code will then automatically validate the token that clients provide in API requests in a token parameter.

If you don't want to use a token that is part of core, but rather a custom token with your own permission checks, use ApiQueryTokensRegisterTypes hook to register your token.

Primary database access

[edit]

If your module accesses the primary database, it should implement the isWriteMode() method to return true.

Returning errors

[edit]

ApiBase includes several methods for performing various checks, for example,

But you will often run into cases where you need to raise an error of your own. The usual way to do that is to call $this→dieWithError(), although if you have a StatusValue with the error information you could pass it to $this→dieStatus() instead.

If you need to issue a warning rather than an error, use $this→addWarning() or $this→addDeprecation() if it's a deprecation warning.

Documentation

[edit]

The API is documented using MediaWiki's i18n mechanism. Needed messages generally have default names based on the module's "path". For action and format modules, the path is the same as the module's name used during registration. For query submodules, it's the name prefixed with query+.

Every module will need a apihelp-$path-summary message, which should be a one-line description of the module. If additional help text is needed, apihelp-$path-extended-description may be created as well. Each parameter will need a apihelp-$path-param-$name message, and parameters using PARAM_HELP_MSG_PER_VALUE will also need a apihelp-$path-paramvalue-$name-$value for each value.

More details on API documentation are available at API:Localisation .

Extensions may also document their extra API modules on mediawiki.org. This should be located on the extension's main page or, if more space is required, on pages named Extension:<ExtensionName>/API or subpages thereof (e.g. CentralAuth , MassMessage , or StructuredDiscussions ). The API namespace is reserved for the API of MediaWiki core.

Extending core modules

[edit]

Since MediaWiki 1.14, it's possible to extend core modules' functionality using the following hooks:

List of extensions with API functionality

[edit]

See Category:API extensions for examples of extensions that add to or extend the API.

Testing your extension

[edit]
  • Visit api.php and navigate to the generated help for your module or query submodule. Your extension's help information should be correct.
    • The example URLs you provided in getExamplesMessages() should appear under "Examples", try clicking them.
    • Omit and mangle URL parameters in the query string, check your extension's response.
  • Visit Special:ApiSandbox and interactively explore your API.
  • To see additional information about your extension:
什么是分子 女性下面水少是什么原因 无奇不有是什么意思 吃紫菜有什么好处和坏处 做宫颈筛查能查出什么
m是什么意思 胃肠化是什么意思 inr是什么意思医学 尿潴留吃什么药 胶原蛋白有什么作用
排便困难拉不出来是什么原因 减肥晚饭吃什么好 常务副省长是什么级别 夏至吃什么传统美食 白酒泡什么补肾壮阳最好
青蛙爱吃什么 成双成对是什么数字 尿微量白蛋白高是什么原因 ldl是什么意思 肺与什么相表里
什么是大小周hcv8jop4ns1r.cn 什么是超纤皮qingzhougame.com 梦见抓鱼是什么预兆hcv9jop3ns7r.cn 惴惴不安什么意思hcv9jop6ns6r.cn 雷龙吃什么creativexi.com
专科和本科有什么区别hcv8jop7ns4r.cn 相濡以沫是什么意思hcv8jop2ns8r.cn 嘴唇干裂脱皮是什么原因hcv9jop3ns2r.cn 怎么判断脸上是什么斑hcv8jop6ns2r.cn 小孩晚上睡觉磨牙是什么原因hcv7jop4ns6r.cn
蒸鱼豉油可以用什么代替hcv8jop5ns0r.cn 吞金为什么会死hcv8jop8ns6r.cn 蜂胶有什么作用和功效hcv7jop9ns0r.cn 苏州有什么好玩的地方xjhesheng.com 嘴角有痣代表什么xjhesheng.com
7月14日什么节日hcv7jop7ns3r.cn 水瓶后面是什么星座520myf.com 经常拉肚子什么原因0735v.com 口水多是什么原因引起的hcv8jop1ns8r.cn 金骏眉是什么茶类hcv8jop8ns2r.cn
百度