1

Wikimedia Commons 有一个新功能来描述图片所描绘的内容。示例

在此处输入图像描述

问题

如何使用wikimedia-android-data-client库调用或 REST HTTP 请求以 JSON 格式获取给定图像的“描述”?

4

1 回答 1

2

您可以使用一些Wikibase API(我认为目前没有详细记录哪些或如何记录)。例如

https://commons.wikimedia.org/w/api.php?action=wbgetclaims&format=jsonfm&entity=M78893847

{
    "claims": {
        "P180": [
            {
                "mainsnak": {
                    "snaktype": "value",
                    "property": "P180",
                    "hash": "7754bb4b4dcf94dd0a6b8524351b22df21328a88",
                    "datavalue": {
                        "value": {
                            "entity-type": "item",
                            "numeric-id": 12280,
                            "id": "Q12280"
                        },
                        "type": "wikibase-entityid"
                    },
                    "datatype": "wikibase-item"
                },
                "type": "statement",
                "id": "M78893847$bf7f116a-4d08-0426-0e81-c9552a89fa63",
                "rank": "preferred"
            },
            {
                "mainsnak": {
                    "snaktype": "value",
                    "property": "P180",
                    "hash": "8ed7e126588c21d3cf88387d5ee875d528c00a74",
                    "datavalue": {
                        "value": {
                            "entity-type": "item",
                            "numeric-id": 1021645,
                            "id": "Q1021645"
                        },
                        "type": "wikibase-entityid"
                    },
                    "datatype": "wikibase-item"
                },
                "type": "statement",
                "id": "M78893847$7830fc04-4a1e-f289-93bc-69d6bbf3b7fd",
                "rank": "normal"
            }
        ]
    }
}

78893847 是您可以通过查询 API获得的页面 ID : https ://commons.wikimedia.org/w/api.php?action=query&format=jsonfm&formatversion=2&titles=File%3AMomoyo-brug%20in%20Shibaura%2C% 20gezien%20richting%20het%20zuidoosten%2C%20-15%20maart%202019.jpg

{
    "batchcomplete": true,
    "query": {
        "pages": [
            {
                "pageid": 78893847,
                "ns": 6,
                "title": "File:Momoyo-brug in Shibaura, gezien richting het zuidoosten, -15 maart 2019.jpg"
            }
        ]
    }
}
于 2019-07-24T09:54:34.673 回答