Calling Yahoo REST web services with Ruby query parameter problems

I’m an idiot and req = Net::HTTP::Get.new(url.path+'?'+url.query) is my friend.

Just playing around with Ruby and the Yahoo Web Services. The example they give for calling a web service is this:

require 'net/http'

url = 'http://api.search.yahoo.com/WebSearchService/V1/webSearch?appid=YahooDemo&query=madonna&results=1'
resp = Net::HTTP.get_response(URI.parse(url)) # get_response takes an URI object

data = resp.body

I am behind a proxy at work, so my code looks like this:

require 'net/http'

@proxy_addr = 'wwwcache.bath.ac.uk'
@proxy_port = 3128

url = URI.parse('http://api.search.yahoo.com/WebSearchService/V1/webSearch?appid=YahooDemo&query=madonna&results=1')

req = Net::HTTP::Get.new(url.path)
res = Net::HTTP::Proxy(@proxy_addr, @proxy_port).start(url.host, url.port) {|http|
    http.request(req)
}

data = res.body

puts data

The response I get is:

<?xml version="1.0" encoding="UTF-8"?>
<Error xmlns="urn:yahoo:api">
  The following errors were detected:
  <Message>invalid value: appid (empty or missing)</Message>
  <Message>invalid value: query (empty or missing)</Message>
</Error>
<!-- ws01.search.re2.yahoo.com uncompressed Wed Nov 29 05:54:50 PST 2006 -->

So the query parameters are being stripped from the GET request. I have no idea why. Any ideas? I’ve not had this problem with making queries through our proxy, although a look with Wireshark could prove that they’re making it through.

Oops – I think I’m actually stripping the parameters myself there by creating a new Get using url.path but even changing to just do a puts http.request_get('WebSearchService/V1/webSearch?appid=YahooDemo&query=madonna&results=1').body doesn’t work, which I thought might have had a better chance.

Dumping BlogBridge

I was doing OK with BlogBridge, but in the last month it’s dropped all my data twice and then prevented me from re-importing all my feeds by disabling all the feed action buttons and menu items such as “add feed, import feed” etc.

Luckily it does an automatic export of your subscription list as OPML every time you make a change to the list of feeds that you read (in %profile%.bbfinalbackups), so importing it into another reader should be easy.

It’s also lucky that I don’t use any of the special features like “pinning”, or smartfeeds, because I’d be royally pissed off; as it is I’m just quite annoyed that I’m going to have to trawl, yet again, the painful mess of Windows desktop aggregators.

Twittering

I’ve finally signed up to twitter now I realise that it’s not SMS-only (because what fool pays for that?) and I can update via IM. It seems cute.

The IM bot didn’t recognise my Jabber address (or at least I didn’t receive anything at that address), although it did pick up my Gmail account. The bot always appears offline to me though, which means that it doesn’t show up in my contact list until I turn on “show offline contacts”, which is very annoying, and means I’ll probably forget all about it.

I’m also quite surprised that there aren’t already a host of plugins which pick up your IM status and post that to Twitter (or vice versa). A single point of entry for desktop status makes sense to me.

I see that there is a script which checks your iChat status and posts that off to Twitter every five minutes, but that’s not quite as integrated as I was hoping for.

Overall, I do like the notion of Twitter, at least in some sense, although, like Phil Gyford I was reasonably surprised that I’d have to set up yet another social network. I did some work on this last year, I’ll see if I can do anything more practical about it. There’s an obvious application for creating your FOAF file and using a service’s API for auto-creating a social network.

XBox 360 advertising splurge

I thought I was going mad this morning as I was reading the metro (a free daily newspaper in the UK) – there seemed to be ads for games *everywhere*. I realised a few pages in that they were all for the Xbox 360.

In fact, it was so outrageously obvious (two two-page spreads, including a Dead Or Alive calendar), that Kotaku also picked up on it and went as far as to photograph all the ads and put them online. To clarify, that’s about 42 ads in a 56-page newspaper.

Note to Microsoft: it is possible for you to spread your marketing you know – you don’t have to blow the budget all on one day!

UK Biometric Passports cracked

I hope that you’re not putting a lot of faith in the new biometric passports (my wife just got one) because any half-capable programmer with an RFID reader can obtain the details stored in them.

Within minutes of applying the three passports to the reader, the information from all of them has been copied and the holders’ images appear on the screen of Laurie’s laptop.

The information on the chip isn’t encrypted, but the conversation with it is, but the key is human-readable from the passport itself. Utter, utter madness.

Sony Ericsson W950i – better than the Nokia N91?

I like Symbian, and I can write code for it. This has mostly limited me to the Nokia brand of phones so far.

I am interested in getting a new phone, but am slightly out of touch on the latest devices.

Hence, my astonishment – the Sony Ericsson W950i runs Symbian.

Also, it appears to come bundled with mobile browser par excellence, Opera 8.

It also has a 4GB memory (can’t yet tell if this is hard drive based like the N91 or flash).

It is a very simple-looking handset, which definitely appeals to me after the years of the 6600 and now my 6630.

I guess the only bad sign to-date is this:

Available colours: Mystic purple

no camera. bugger.