« Module:ZoteroAPI » : différence entre les versions
Aller à la navigation
Aller à la recherche
Aucun résumé des modifications |
Aucun résumé des modifications |
||
| Ligne 9 : | Ligne 9 : | ||
local url = 'https://api.zotero.org/groups/4893620/items/' .. itemKey .. '?include=data&format=json' | local url = 'https://api.zotero.org/groups/4893620/items/' .. itemKey .. '?include=data&format=json' | ||
local | local result = mw.ext.externalData.getExternalData({ | ||
url = url, | url = url, | ||
format = 'json' | format = 'json' | ||
}) | }) | ||
if not | if not result or type(result) ~= 'table' then | ||
return '❌ Aucune donnée reçue | return '❌ Aucune donnée reçue.' | ||
end | end | ||
return '<pre>' .. | -- Représente le tableau Lua en JSON formaté | ||
local ok, json = pcall(mw.text.jsonEncode, result) | |||
if not ok then | |||
return '❌ Erreur lors de l’encodage JSON.' | |||
end | |||
return '<pre>' .. json .. '</pre>' | |||
end | end | ||
return p | return p | ||
Version du 11 juin 2025 à 15:57
La documentation pour ce module peut être créée à Module:ZoteroAPI/doc
local p = {}
function p.getItemRawJson(frame)
local itemKey = frame.args[1]
if not itemKey or itemKey == '' then
return '❌ Aucun itemKey fourni.'
end
local url = 'https://api.zotero.org/groups/4893620/items/' .. itemKey .. '?include=data&format=json'
local result = mw.ext.externalData.getExternalData({
url = url,
format = 'json'
})
if not result or type(result) ~= 'table' then
return '❌ Aucune donnée reçue.'
end
-- Représente le tableau Lua en JSON formaté
local ok, json = pcall(mw.text.jsonEncode, result)
if not ok then
return '❌ Erreur lors de l’encodage JSON.'
end
return '<pre>' .. json .. '</pre>'
end
return p