Module:ZoteroItem
La documentation pour ce module peut être créée à Module:ZoteroItem/doc
local p = {}
function p.getItem(frame)
local key = frame.args[1]
if not key or key == "" then
return "Erreur : aucun itemKey fourni"
end
local groupId = frame.args.groupId or "4893620"
local url = string.format(
"https://api.zotero.org/groups/%s/items/%s?format=json&include=data",
mw.uri.encode(groupId),
mw.uri.encode(key)
)
local t, errs = mw.ext.externalData.getWebData{
url = url,
format = "JSON"
}
if errs then
return "Erreur HTTP ou parsing : " .. table.concat(errs, "; ")
end
if not t then
return "Aucun résultat, possible timeout ou erreur silencieuse"
end
if not t.__json then
return "Résultat inattendu : " .. mw.text.jsonEncode(t)
end
local d = t.__json.data
if not d then
return "Aucun champ 'data' dans la réponse"
end
-- traitement normal...
end
return p