如何在每个页面顶部添加特定行 (Mediawiki)

How to add a specific line on top of each page (Mediawiki)

我想将 VoteNY 扩展添加到我的 wiki,这样所有用户都可以互相评价。此扩展需要行

<vote type="1"></vote>

在每个应该可以投票的页面上。 现在我正在尝试 最初 以编程方式将这些行写在每一页(~10000 页)的顶部。我已经找到了一个钩子来在创建新文章时添加该行。但是每一页都应该有这一行。

这是我目前拥有的:

<?php
$TitleList = [];    
# get the edit ticket
$jsn = file_get_contents('http://wiki/api.php?action=query&meta=tokens&format=json');
$json_a = json_decode($jsn, true);
$token = $json_a['query']['tokens']['csrftoken'];

# populate the list of all pages
$urlGET = 'http://wiki/api.php?action=query&list=allpages&format=json';
$json = file_get_contents($urlGET);
$json_b = json_decode( $json ,true);
foreach  ($json_b['query']['allpages'] as $page)
{
    array_push($TitleList, $page['title']);
}

# //add the line on top of every page
foreach ($TitleList as $title)
{
    $data = array(
        'action'      => 'edit',
        'title'       => $title,
        'prependtext' => '<vote type="1"></vote>',
        'token'       => $token);
    # Create a connection
    $url = 'http://wiki/api.php?';
    $ch = curl_init($url);
    # Form data string, automatically urlencode
    $postString = http_build_query($data, '', '&');
    # Setting our options
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postString);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    # Get the response
    $response = curl_exec($ch);
    curl_close($ch);            
    echo($response);    
}

目前可以正常使用。但我认识到 &list=allpages 没有给我 wiki 的所有页面(40% 丢失)。

感谢评论中的提示和提示。我设法让脚本 运行 正确。我编辑了我的问题。