2011-12-26 7 views
0

私はembed.ly APIを使用していますが、サンプルコードを使用すると、データの長い文字列を取得するだけで、オブジェクトの別の部分にアクセスできるオブジェクトではなく、ここに私のコードです:embedlyから返されたwhatsのアクセス部分

embedly_api = Embedly::API.new :key => 'HIDDEN', :user_agent => 'Mozilla/5.0 (compatible; mytestapp/1.0; [email protected])' 
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 

OBJ [0]が返されます。

{: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} 

私が欲しいもの[0] .provider_url、説明のように...どのようにOBJにアクセスするのですか?

答えて

1
obj[0][:provider_url] 

はすべきことです。

+0

ありがとうございます!非常に明白な今私は答えを参照してください:) – hso

+0

あなたがすでに知っているものを見るためにあなたは他の目が必要になることが時々起こります:) – lucapette

関連する問題