Problems with RemoteRequest

34 views
Skip to first unread message

Konzertheld

unread,
Aug 16, 2013, 10:15:53 PM8/16/13
to habar...@googlegroups.com
Hi everyone,

here's another weird issue I came across.

I'm trying to access Atom feeds of Wiki watchlists. Those require passing a token and a list of &ed parameters. It turned out I can't receive the feed because the token is not transmitted correctly for some reason. Testing with CURL myself, the same problem occured, but only if I did not put single quotes around the URL. Using single quotes or escaping all the &s with \ made it work for CURL in a bash. Now what should I do to make the links work with Habari's RemoteRequest?

Those of you having an account in the Habari Wiki can test themselves:

1. Get the feed link for your watchlist (it's in the sidebar)
2. Throw it into RemoteRequest::get_contents()
3. Throw it into CURL in a terminal
4. Throw it into CURL in a terminal, enclosed in single quotes

Only the last one will show your watchlist.

I'm quite sure the problem is somewhere on the way between my or Habari's code setting up the request and CURL itself. So if you have any ideas, it will be appreciated.

Konzertheld

Colin

unread,
Aug 20, 2013, 10:34:28 AM8/20/13
to habar...@googlegroups.com
The behaviour you describe in bash is expected as the shell will interpret the first non-escaped & (to background the process) and ignore the rest unless you escape or quote the individual & chars or the entire string.

As for using RemoteRequest, there should be nothing to do other than put your URL in quotes. The following works perfectly for me in 0.9.1...

$output = RemoteRequest::get_contents( 'http://wiki.habariproject.org/w/api.php?action=feedwatchlist&allrev=allrev&wlowner=Lildude&wltoken=<TOKEN>&feedformat=atom' );
Utils::debug( $output );

I get the following in the debug output:

---
string <?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://wiki.habariproject.org/w/skins/common/feed.css?270"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
<title>Habari Project - My watchlist [en]</title>
<link rel="self" type="application/atom+xml" href="http://wiki.habariproject.org/w/api.php?action=feedwatchlist&amp;allrev=allrev&amp;wlowner=Lildude&amp;wltoken=<TOKEN>&amp;feedformat=atom"/>
<link rel="alternate" type="text/html" href="http://wiki.habariproject.org/en/Special:Watchlist"/>
<updated>2013-08-20T14:26:01Z</updated>
<subtitle>My watchlist</subtitle>
<generator>MediaWiki 1.16.1</generator>

</feed>
---




--
--
To post to this group, send email to habar...@googlegroups.com
To unsubscribe from this group, send email to habari-dev-...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/habari-dev
---
You received this message because you are subscribed to the Google Groups "habari-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to habari-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Colin Seymour
Blog: http://colinseymour.co.uk
Tech Stuff: http://lildude.co.uk
Barefoot Running: http://barefootrunner.co.uk
IRC: lildude #habari

Konzertheld

unread,
Sep 25, 2013, 5:45:36 PM9/25/13
to habar...@googlegroups.com
Hm. I get that result now, too (no idea why it works), but it's always empty, even for Wikipedia, where my watchlist shows results. Could you watch one of the pages I recently edited (like http://wiki.habariproject.org/en/Release_Cycle) and see if your watchlist feed contains entries? I can't test because there are no recent changes in the wiki except mine...

Colin

unread,
Sep 25, 2013, 6:11:29 PM9/25/13
to habar...@googlegroups.com
Hmmm, I also always get an empty watch list.


On 25 September 2013 14:45, Konzertheld <christia...@gmail.com> wrote:
Hm. I get that result now, too (no idea why it works), but it's always empty, even for Wikipedia, where my watchlist shows results. Could you watch one of the pages I recently edited (like http://wiki.habariproject.org/en/Release_Cycle) and see if your watchlist feed contains entries? I can't test because there are no recent changes in the wiki except mine...

--
--
To post to this group, send email to habar...@googlegroups.com
To unsubscribe from this group, send email to habari-dev-...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/habari-dev
---
You received this message because you are subscribed to the Google Groups "habari-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to habari-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Colin

unread,
Sep 25, 2013, 6:19:28 PM9/25/13
to habar...@googlegroups.com
Bingo!!!!  I've looked further into this the problem is the timeframe the watchlist reports for. By default it only shows changes for the last 24 hours (discovered this at http://www.mediawiki.org/wiki/API:Watchlist_feed ).

So I tested this and modified the Release Policy page (I added a "." to the very end of it) and sure enough, my watchlist now shows this modification on both the Wiki and within the feed.

If you check your feed within the next 24 hours you should see it has my change in it.  Alternatively, add hours=72 to the URL to get the last 72 hours' worth of updates.

Chris Meller

unread,
Sep 25, 2013, 8:04:25 PM9/25/13
to habar...@googlegroups.com
Are we sure it's not whatever hard coded time period the feeds use? There haven't been edits in a while, so my tests showed the same thing earlier. 

Chris Meller

unread,
Sep 25, 2013, 8:06:14 PM9/25/13
to Habari Dev
Confirmed, at least for my case: http://cl.ly/image/1D1I1B0u1d1O

Once Colin made his edit, it showed up in my watch list atom feed.

Konzertheld

unread,
Sep 27, 2013, 5:32:03 AM9/27/13
to habar...@googlegroups.com
Hmm. When I add the hours parameter to the URL, I can see edits. Thanks for the hint. While RemoteRequest::get_contents() works when called from HConsole, it still retrieves error pages when executed from the plugin code... weird.

Konzertheld

unread,
Apr 20, 2014, 5:17:03 PM4/20/14
to habar...@googlegroups.com
Re-visiting the problem I was now able to fix this issue... I was grabbing the URL via something like handler_vars['url'], which got me an escaped URL which RemoteRequest can't handle (all the & became &amp;). I'm not sure if that's intended behaviour. Anyway, using handler_vars->raw('url') instead did the trick, delivered the unescaped URL and now I can access the feed.

Chris Meller

unread,
Apr 20, 2014, 10:02:42 PM4/20/14
to Habari Dev
I’m not sure which bit you are referring to when you say you’re not sure if it’s intended behavior, but they both are. HandlerVars is an instance of SuperGlobal, so the escaping is intended (XSS protection and what not). RR does not do anything with the URL (the escaping may be completely intention), so that’s also intended.


-- 
-- 
To post to this group, send email to habar...@googlegroups.com
To unsubscribe from this group, send email to habari-dev-...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/habari-dev
--- 
You received this message because you are subscribed to the Google Groups "habari-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to habari-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages