Planet samurai-x

July 26, 2011

Jochen Maes

Yahoo boss v2 with twisted.

\\//,

So I've been kinda busy with brekiri :p. Hence the silence. However as it took me a while to figure out how to get the new Yahoo boss api working in twisted. Here is how you do it:

keywords="Yahoo search isn't that easy anymore"
CONSUMER_KEY='I is a key'
CONSUMER_SECRET='Secret am I'
url = "https://yboss.yahooapis.com/ysearch/web"
consumer = oauth2.Consumer(key=CONSUMER_KEY,secret=CONSUMER_SECRET)
req = oauth2.Request(method = 'GET', url=url,
        parameters = {
            'oauth_version': '1.0',
            'oauth_nonce': oauth2.generate_nonce(),
            'oauth_timestamp': int(time.time()),
            'q': urllib.quote(keywords),
            'format':'json'
        })
req.sign_request(oauth2.SignatureMethod_HMAC_SHA1(), consumer, None)
page = getPage(str(req.to_url()))
page.addCallback(self.result)
page.addErrback(self.error)

tadaaaaa!

llap!

July 26, 2011 02:14 PM