Search code examples
multidimensional-arrayruby-on-rails-3.1embedding

access parts of whats returned from embedly


I am using embed.ly API, but when using example code i just get a long string of data and not an object i can access the different parts of, here is my code:

embedly_api = Embedly::API.new :key => 'HIDDEN', :user_agent => 'Mozilla/5.0 (compatible; mytestapp/1.0; my@email.com)'
url = 'http://www.guardian.co.uk/media/2011/jan/21/andy-coulson-phone-hacking-statement'
obj = embedly_api.oembed :url => url

obj[0].marshal_dump

The obj[0] returns:

{:provider_url=>"http://www.guardian.co.uk/", :description=>"11.25am: Andy Coulson, the the director of communications at No 10, is to make a \"personal statement\". He has been under pressure in recent months over the phone-hacking scandal, with a slew of revelations in a number of civil court cases that appeared to bring the scandal closer to his door.", :title=>"Andy Coulson resigns – as it happened", :url=>"http://www.guardian.co.uk/media/2011/jan/21/andy-coulson-phone-hacking-statement", :thumbnail_width=>140, :thumbnail_url=>"https://static-secure.guim.co.uk/sys-images/Guardian/Pix/pictures/2011/1/14/1295010840306/Andy-Coulson-003.jpg", :version=>"1.0", :provider_name=>"Guardian", :type=>"link", :thumbnail_height=>84}

What i want is to access obj[0].provider_url, description and so on... how?


Solution

  • obj[0][:provider_url]
    

    should do the trick.