json - Pulling posts from tumblr with ruby -


i trying figure out how pull posts specific tumblr account ruby. end goal have hash post number => text. looking text , each post number.

i tried following (for demo.tumblr.com):

require 'open-uri' require 'json'  jtest = json.load(open("http://api.tumblr.com/v2/blog/demo.tumblr.com/posts/text?api_key=fuiknfp9vqfvjlnvx4suwti4yb5ygutbn4xh10lxzhhrkjwlv4&notes_info=true&filter=text")) puts jtest 

which gives me, i'm going put snippet of it:

{"meta"=>{"status"=>200, "msg"=>"ok"}, "response"=>{"blog"=>{"title"=>"demo", "name"=>"demo", "posts"=>7, "url"=>"http://demo.tumblr.com/", "updated"=>1269024321, "description"=>"lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.", "is_nsfw"=>false, "ask"=>false, "ask_page_title"=>"ask me anything", "ask_anon"=>false, "share_likes"=>false}, "posts"=>[{"blog_name"=>"demo", "id"=>459009076, "post_url"=>"http://demo.tumblr.com/post/459009076/lorem-ipsum-dolor-sit-amet-consectetuer", "slug"=>"lorem-ipsum-dolor-sit-amet-consectetuer", "type"=>"text", "date"=>"2006-10-01 04:00:00 gmt", "timestamp"=>1159675200, "state"=>"published", "format"=>"html", "reblog_key"=>"uht0tehp", "tags"=>[], "short_url"=>"http://tmblr.co/zg4ybyrm_mq", "highlighted"=>[], "note_count"=>5793, "title"=>"", "body"=>"lorem ipsum dolor sit amet, consectetuer adipiscing elit. aliquam nisi lorem, pulvinar id, commodo feugiat, vehicula et, mauris. aliquam mattis porta urna. maecenas dui neque, rhoncus sed, vehicula vitae, auctor at, nisi. aenean id massa ut lacus molestie porta. curabitur sit amet quam id libero suscipit venenatis.", "notes"=>[{"timestamp"=>"1429905090", "blog_name"=>"hdpreview2", "blog_url"=>"http://hdpreview2.tumblr.com/", "post_id"=>"117273527904", "type"=>"reblog"} 

it goes on while not sure how drill down that. seems jtest hash 2 items, first

{meta => {"status"=>200, "msg"=>"ok"}} 

and second is:

{response => rest of that.... 

i in on head cannot wrap head around how text posts out of tumblr blog via ruby.

what you're asking how access values in hash. i'm sure there's plenty of precedent here on so.

but started, here examples:

jtest["meta"]["status"] #=> 200 jtest["response"]["blog"]["title"] #=> "demo" 

at point can inspect output. using pp nicer formatting.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -