[Developers] MQL for Ruby?
David Dennis
davdennis at gmail.com
Sat Mar 14 03:39:34 UTC 2009
THANKS!
But please also warn people in the future to run "gem install echoe" first.
On Fri, Mar 13, 2009 at 10:14 PM, Shawn Simister <narphorium at gmail.com>wrote:
> The HTTParty gem is a great way to get started with MQL in Ruby. Here's
> some sample code to get you started.
>
> require 'httparty'
>
> class Freebase
> include HTTParty
> format :json
> base_uri 'http://www.freebase.com/api'
>
> def self.read(q)
> return get('/service/mqlread?', :query => {:query => '{"query":' + q +
> '}'})['result']
> end
> end
>
> query = '{"id":"/en/peru","capital":null,"type":"/location/country"}'
> puts Freebase.read(query)['capital']
>
> This code will query Freebase to find the capital of Peru and will write
> the result to the console.
>
> Shawn
>
> David Dennis wrote:
>
> From looking around it seems like there's no gem set up for this yet.
>
> For some reason even running a basic "open()" from "open-uri" doesn't
> allow me to retrieve any text when I include a Freebase query url as a
> parameter. I can usually retrieve HTML this way (e.g.,
> http://www.google.com still works). Why would does it not work for the
> Freebase query URLs?
> I just want to get some text on screen to start with. Have any other
> rails people had luck?
>
> Thanks,
> David
>
> ------------------------------
> _______________________________________________
> Developers mailing listDevelopers at freebase.comhttp://lists.freebase.com/mailman/listinfo/developers
>
>
>
> _______________________________________________
> Developers mailing list
> Developers at freebase.com
> http://lists.freebase.com/mailman/listinfo/developers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freebase.com/pipermail/developers/attachments/20090313/0d1a9ba2/attachment-0001.htm
More information about the Developers
mailing list