١٬٠٢٢
تعديل
لا ملخص تعديل |
لا ملخص تعديل |
||
| سطر ٦: | سطر ٦: | ||
local wiki_api_endpoint = mw.uri.new("https://ar.ciyaye-kurmenc.com/api.php") | local wiki_api_endpoint = mw.uri.new("https://ar.ciyaye-kurmenc.com/api.php") | ||
local category_name = "قرى_منطقة_عفرين" | local category_name = "قرى_منطقة_عفرين" | ||
local params = { | |||
action = "query", | action = "query", | ||
format = "json", | format = "json", | ||
| سطر ٢٠: | سطر ١٩: | ||
local url = wiki_api_endpoint:extendWithPath("api.php"):setQuery(params):fullUrl() | local url = wiki_api_endpoint:extendWithPath("api.php"):setQuery(params):fullUrl() | ||
local | local response = mw.http.get(url) | ||
if data and data.query and data.query.categorymembers and #data.query.categorymembers > 0 then | if response then | ||
local data = mw.text.jsonDecode(response) | |||
if data and data.query and data.query.categorymembers and #data.query.categorymembers > 0 then | |||
local last_article_title = data.query.categorymembers[1].title | |||
return "<h2>Last Article in " .. category_name .. " Category:</h2><p>" .. last_article_title .. "</p>" | |||
else | |||
return "<p>No articles found in the " .. category_name .. " category.</p>" | |||
end | |||
else | else | ||
return "<p> | return "<p>Error fetching data from the API.</p>" | ||
end | end | ||
end | end | ||
return p | |||