如何使用API​​获取当前的MediaWiki版本?

时间:2017-06-05 18:26:43

标签: mediawiki mediawiki-api

使用MediaWiki API如何获取版本号?

1 个答案:

答案 0 :(得分:1)

您需要/w/api.php?action=query&format=json&prop=&meta=siteinfo。这将为您提供所需的一切(以及更多)。以下是它从en.wikipedia.org返回的内容:

{
    "batchcomplete": "",
    "query": {
        "general": {
            "mainpage": "Main Page",
            "base": "https://en.wikipedia.org/wiki/Main_Page",
            "sitename": "Wikipedia",
            "logo": "//en.wikipedia.org/static/images/project-logos/enwiki.png",
            "generator": "MediaWiki 1.30.0-wmf.2",
            "phpversion": "5.6.99-hhvm",
            "phpsapi": "srv",
            "hhvmversion": "3.18.2",
            "dbtype": "mysql",
            "dbversion": "10.0.29-MariaDB",
            "imagewhitelistenabled": "",
            "langconversion": "",
            "titleconversion": "",
            "linkprefixcharset": "",
            "linkprefix": "",
            "linktrail": "/^([a-z]+)(.*)$/sD",
            "legaltitlechars": " %!\"$&'()*,\\-.\\/0-9:;=?@A-Z\\\\^_`a-z~\\x80-\\xFF+",
            "invalidusernamechars": "@:",
            "fixarabicunicode": "",
            "fixmalayalamunicode": "",
            "git-hash": "b40805ff461884e48400adb3000fa06f9b6ff4c9",
            "git-branch": "wmf/1.30.0-wmf.2",
            "case": "first-letter",
            "lang": "en",
            "fallback": [],
            "fallback8bitEncoding": "windows-1252",
            "writeapi": "",
            "maxarticlesize": 2097152,
            "timezone": "UTC",
            "timeoffset": 0,
            "articlepath": "/wiki/$1",
            "scriptpath": "/w",
            "script": "/w/index.php",
            "variantarticlepath": false,
            "server": "//en.wikipedia.org",
            "servername": "en.wikipedia.org",
            "wikiid": "enwiki",
            "time": "2017-06-05T23:28:54Z",
            "misermode": "",
            "uploadsenabled": "",
            "maxuploadsize": 4294967296,
            "minuploadchunksize": 1024,
            "galleryoptions": {
                "imagesPerRow": 0,
                "imageWidth": 120,
                "imageHeight": 120,
                "captionLength": "",
                "showBytes": "",
                "mode": "traditional"
            },
            "thumblimits": [
                120,
                150,
                180,
                200,
                220,
                250,
                300,
                400
            ],
            "imagelimits": [
                {
                    "width": 320,
                    "height": 240
                },
                {
                    "width": 640,
                    "height": 480
                },
                {
                    "width": 800,
                    "height": 600
                },
                {
                    "width": 1024,
                    "height": 768
                },
                {
                    "width": 1280,
                    "height": 1024
                }
            ],
            "favicon": "//en.wikipedia.org/static/favicon/wikipedia.ico",
            "centralidlookupprovider": "CentralAuth",
            "allcentralidlookupproviders": [
                "CentralAuth",
                "local"
            ],
            "interwikimagic": "",
            "magiclinks": {
                "ISBN": "",
                "PMID": "",
                "RFC": ""
            },
            "wmf-config": {
                "wmfMasterDatacenter": "eqiad"
            },
            "pageviewservice-supported-metrics": {
                "pageviews": {
                    "pageviews": ""
                },
                "siteviews": {
                    "pageviews": "",
                    "uniques": ""
                },
                "mostviewed": {
                    "pageviews": ""
                }
            }
        }
    }
}

我猜你需要那个“发电机”属性。如果您愿意,可以在维基百科的API sandbox中进行测试。