Topic on Project:Support desk

feed from private wiki

15
129.27.104.9 (talkcontribs)

We have a private wiki:

  • MediaWiki 1.23.5
  • PHP 5.3.3-7+squeeze21
  • MySQL 5.1.73-1


Is there a way to read feeds from our wiki without a login? Is there something like the $wgWhitelistRead variable for feeds?

Can somebody help me, thanks in advance!

Greetings, Stefan

Florianschmidtwelzow (talkcontribs)

Which feeds? Watchlist feed? Recentchanges?

129.27.104.9 (talkcontribs)

mainly the watchlist feed, recentchanges and new sides are also interesting

Florianschmidtwelzow (talkcontribs)

And now the question is: What means private :) You mean that all users must login to read the content?

For watchlists, you can use Watchlist tokens.

129.27.104.9 (talkcontribs)

Yes, all users must login to read the content. I also don't see changes in the watchlist feed if I use tokens and I'm not logged in.

Tenbergen (talkcontribs)

I am not the original poster but am also looking into getting Recent Changes RSS feeds to work from a wiki that requires login for access. I use tinytinyRSS, a web based feed aggregator. It's set up so that clicking on an RSS feed link generates a new feed. When I click on the recent changes RSS link in wikipedia, it creates a working link. When I click the same button in our password protected mediawiki it gives me an error:

No feeds found in http://ccmdb.kuality.ca/api.php?hidebots=1&days=7&limit=50&action=feedrecentchanges&feedformat=rss
Tenbergen (talkcontribs)

When I look at the feed from a different browser that is not set up to push rss links into tinyRSS. When I am logged in I get something that looks like an RSS feed. When I log out I get the API instructions, preceded by

<?xml version="1.0"?>
 <api>
  <error code="readapidenied" info="You need read permission to use this module" xml:space="preserve">
Tenbergen (talkcontribs)

When I look at the error in TinyRSS it says "LibXML error 5 at line 3217 (column 1): Extra content at the end of the document"

When I copy and paste the API response into Notepad++ to count lines it only seems to have 3206.

Ciencia Al Poder (talkcontribs)

Firefox -> view source code: It displays line numbers, and it indeed has more than 3217 lines.

There's no point in having a private wiki and also leak a recent changes feed. Sorry, but I don't think you would get support for opening that feed on a private wiki.

Tenbergen (talkcontribs)

Thanks for the source code hint, I was looking at the rendered page. Looking at the source code hint, it appears that the complaint is about the script section at the very end. Which makes sense, it expects an XML document and instead receives an html document with a script at the end. The RSS reader can't interpret that, so to get any meaningful idea what is going on takes a fair bit. I think it might make more sense if, in response to a feed request, the api generated a "feed" that states the error?

Regarding the login requirement, I am not trying to get the feed to bypass it. TinyRSS can provide a login account and password, it just isn't working. I am trying to find out more about that.

Tenbergen (talkcontribs)

TinyRSS forums got back saying that for an authenticated feed listing to work, "http basic/digest auth" needs to be supported and that "digest authentication requires curl". Does Mediawiki work like that?

Tenbergen (talkcontribs)

I am still trying to figure this one out. https://en.wikipedia.org/wiki/Wikipedia:Syndication#Watchlist_feed_with_token makes it sound like I should be able to read at least my watch list as long as I give it the token from preferences, following pattern http://en.wikipedia.org/w/api.php?action=feedwatchlist&wlowner=USERNAME&wltoken=TOKEN. I get exactly the same error. If I understand right the whole purpose of the token is to be able to access things without having to log on. Am I misunderstanding this? T

Ciencia Al Poder (talkcontribs)

You are correct. But still you need readapi rights, since that's the first thing that gets checked, and logged out users don't have that right in your wiki. This may or may not be considered a bug.

You may try to file a BUGREPORT about that so the readapi right is checked in this case for the user in wlowner, if the providen token is correct.

Tenbergen (talkcontribs)

Already reported in bug tracker, first for the inability for my RSS aggregator to log in (https://phabricator.wikimedia.org/T92469) and then seconded a pre-existing report that the watchlist token would still require login (https://phabricator.wikimedia.org/T76528). I had not initially thought to search for a watchlist bug, what I really want to see is recent changes, but I could make watchlist work by adding all articles to my watchlist. Nuisance, but... As it is, the only use I could see for the watchlist token is to log in and be able to monitor a different user's watchlist via token. Not sure what that would be good for, but hey...

Gorantornqvist (talkcontribs)
<?php
// Simple wrapper script to allow access to MediaWiki Recent changes without authentication.

// REST library , may be better ones out there.
// https://github.com/nischayn22/MediaWiki_Api
require_once( 'mediawikiapi.php' );
// NOTE: I needed to add trim($data) in mediawikiapi.php everywhere where simplexml_load_string was used to work with mediawiki.
// Custom additions to above lib:
/*
function getFeedRecentChanges($days, $limit) {
        $url  = $this->siteUrl . "/api.php?days=$days&limit=$limit&action=feedrecentchanges&feedformat=atom";
        $data = httpRequest($url, $params = '');
        $xml  = simplexml_load_string(trim($data));
        errorHandler($xml);
        return $xml;
}
*/


// Config - PS: HTTPS is recommended
$mediawikiurl = "https://my-mediawiki/api.php";

// API Login credentials, create this mediawiki user.
$username = "rss";
$password = 'ThisIsMySecretPassword';

// Primitive authentication - The secret that needs to be passed by querystring to access the page rss.php
// rss.php?secret=blahablaha
$secret = "c5f63b6039e347a5899c8b3cc5e45966";

if ($_GET['secret'] != $secret) {
  die("Secret is incorrect!");
}

if (isset($_GET['days'])) {
  $days = $_GET['days'];
} else {
  $days = "7";
}

if (isset($_GET['limit'])) {
  $limit = $_GET['limit'];
} else {
  $limit = "50";
}

$api = new MediaWikiApi($mediawikiurl);
$api->login($username, $password);
$xml = $api->getFeedRecentChanges($days, $limit);

header("Content-Type: application/xml");
print $xml->asXML();

?>
Reply to "feed from private wiki"