suburbia

Premshree's (品速力) Personal Weblog

etc.

Ruby wrapper for Yahoo! Browser-Based Authentication
suburbia
[info]premshree

As you probably know we launched Browser-Based Authentication. What this means is that users can grant third-party web-based applications access to their Yahoo! data. (Actually, this could be used for non web-based apps too.) For a more detailed explanation, go here.

Anyway, I’ll explain how this works using the Ruby interface I just wrote and (sorta) tested:

  • Registering your web application: First off, you need to register your web application. After registration you’ll get your appid and shared secret.
  • Logging-in users:

    obj = YBBAuth.new(appid, secret)
    obj.get_auth_url('')

    Once you get the auth URL, direct the user there. Now the user is informed that your amazing web application is asking for permissions (read, write or both) and whether he wishes to grant permission, etc. Once the user grants permission, Yahoo! will redirect the user to your application (you would’ve submitted the URL when registering for an appid).
  • Getting user credentials: When Yahoo! redirects the user, it adds a token parameter to the URL. You need to extract this token in order to get user credentials:

    obj.get_access_credentials(token)

  • Making an authenticated request: Now you can make authenticated GET/POST requests:

    obj.ws_auth_get_request('http://photos.yahooapis.com/V3.0/listAlbums')

    The above snippet makes use of the Yahoo! Photos API.

» The Ruby wrapper

The interface isn’t complete or well-tested (I have a flight to catch in a few hours so I need to leave in a bit). I’ll work on it in a day or two.


YDN Ruby
suburbia
[info]premshree

Alright, long time. Long story for some other day. I have been posting stuff to Flickr, though.

Just wanted to let you guys know that we just went live with the Ruby Developer Center on the Yahoo! Developer Network. If you’ve hacked something in Ruby that makes use of Yahoo!’s web services, let me know. Of course, let me know if you have any feedback.

Official post on the YDN blog.

Tags: , , ,

My Web 2.0 Search Results URL Tags Displayer
suburbia
[info]premshree

More Greasemonkey:

Well, if you haven’t figured, the script displays tags (tagged by My Web 2.0 users) for URLs for search results from Yahoo! and Google.

Good night from Monkeyland.


My Web 2.0 Page Tags Displayer
suburbia
[info]premshree

Yellow from Monkeyland once again.

My Web 2.0 is cool, as all of you’ll know. And we have an API—that means uber-cool shit. So, yeah, I hacked a little Greasemonkey script that does this:

Yeah, well, in case you didn’t get it, it basically displays the top (latest?—I’m not sure, and didn’t care to check) tags that the page you’re viewing has been tagged with by My Web 2.0 users. The screenshot above is a section from news.google.com. The thingie at the bottom-right is what the script does.

That’s it from Monkeyland for now.


libyws
suburbia
[info]premshree

Now the we have MyWeb 2.0 (which by the way, is quite cool. I could imagine doing tons of things with it.), it’s time for an update to the Ruby interface to YWSyahoo-ruby 0.2.

Do cool stuff:

require 'yahoo-ruby.rb'
obj = RelatedTags.new('yahoo-ruby', 'ruby', '', '', '', 1)
obj.parse_results.each { |ele|
        ele.each { |k,v|
                print "#{k} => #{v}\n" if v!=nil
        }
}

# Output
Tag => rails
Frequency => 23
Date => 1120011775

The code’s been lying around for some time (observe the date—June 29), but I didn’t release it assuming there’d be an official release or something. Oh well.

I think I’m gonna make major changes to the code. It works well, mind you. However, I’m not satisfied with the design. Ideally I’d like to simply parse the XSD, and spit out a hash. That’d mean each time a new API comes out, I just have to add another schema location to the existing bunch. And I’m not terribly sure I can do that with REXML. Maybe I’m wrong, though, because, honestly, I haven’s dug into it very deep. Oh yeah, I’m gonna move the project to RubyForge.