[Developers] MQL for Ruby?
Shawn Simister
narphorium at gmail.com
Sat Mar 14 02:14:29 UTC 2009
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 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/f8e21451/attachment.htm
More information about the Developers
mailing list