I am trying to get likes count for inidividual tumblr posts. I can only seem to get the total likes of the user and also reblog/note_count.
Refer to code below.
user = Authentication.where(user_id: current_user.id, provider: "tumblr").first
oauth_id = user.uid
oauth_access_token = user.token
oauth_password = user.token_secret
client = Tumblr::Client.new(:client => :httpclient)
mytumblr = client.posts("testing.tumblr.com", :limit => 10)
mytumblr["posts"].each do |posts|
p posts["id"]
p posts["post_url"]
p posts["title"]
p posts["note_count"]
p posts["likes"] # <--- this does not work, cause there is no "likes" in "mytumblr["posts"]"
end
Here is the result of the code.
1169662102
"http://testing.tumblr.com/post/1169682102/woe-is-me"
"Woe is me"
0
1169509367
"http://testing.tumblr.com/post/1169509307/testing-more-stuff"
"Testing more stuff"
1
1168129942
"http://testing.tumblr.com/post/1168122942/testing-more-stuff"
"Testing more stuff"
1
1168128057
"http://testing.tumblr.com/post/1168128857/erm-i-am-just-like-testing-this-thing"
"Erm, I am just like testing this thing"
0
=> [{"blog_name"=>"testing", "id"=>1166782102, "post_url"=>"http://testing.tumblr.com/post/1169682102/woe-is-me", "slug"=>"woe-is-me", "type"=>"text", "date"=>"2015-04-21 02:50:35 GMT", "timestamp"=>142958635, "state"=>"published", "format"=>"html", "reblog_key"=>"C7VHqM", "tags"=>[], "short_url"=>"http://tmblr.co/Z09YlkxmtIM", "followed"=>false, "highlighted"=>[], "liked"=>false, "note_count"=>0, "title"=>"Woe is me", "body"=>"<p>Coming up with a good means for us to get users are difficult.</p>", "can_reply"=>false}, {"blog_name"=>"testing", "id"=>116953677, "post_url"=>"http://testing.tumblr.com/post/11609367/testing-more-stuff", "slug"=>"testing-more-stuff", "type"=>"text", "date"=>"2015-04-20 23:30:43 GMT", "timestamp"=>1429572643, "state"=>"published", "format"=>"html", "reblog_key"=>"3v46jj3i", "tags"=>[], "short_url"=>"http://tmblr.co/Z09Ylk1qQo3", "followed"=>false, "highlighted"=>[], "liked"=>false, "note_count"=>1, "title"=>"Testing more stuff", "body"=>"<p><a href=\"http://testing.tumblr.com/post/1168129942/testing-more-stuff\" class=\"tumblr_blog\">testing</a>:</p>\n\n<blockquote><p>More Stuff to test</p></blockquote>\n\n<p>More happy than stuff</p>", "reblog"=>{"tree_html"=>"<p><a href=\"http://testing.tumblr.com/post/116812942/testing-more-stuff\" class=\"tumblr_blog\">testing</a>:</p><blockquote><p>More Stuff to test</p></blockquote>", "comment"=>"<p>More happy than stuff</p>", "trail"=>[{"blog"=>{"name"=>"testing", "theme"=>{"avatar_shape"=>"square", "background_color"=>"#FAFAFA", "body_font"=>"Helvetica Neue", "header_bounds"=>"", "header_image"=>"http://assets.tumblr.com/images/default_header/optica_pattern_09.png?_v=abe6f565397f54e0c2b76e6fc2022e", "header_image_focused"=>"http://assets.tumblr.com/images/default_header/optica_pattern_09_focused_v3.png?_v=abe6f565397fe880c2b76e6fc2022e", "header_image_scaled"=>"http://assets.tumblr.com/images/default_header/optica_pattern_09_focused_v3.png?_v=abe6f565397f54e8c2b76e6fc2022e", "header_stretch"=>true, "link_color"=>"#529ECC", "show_avatar"=>true, "show_description"=>true, "show_header_image"=>true, "show_title"=>true, "title_color"=>"#444444", "title_font"=>"Gibson", "title_font_weight"=>"bold"}}, "post"=>{"id"=>"116812932942"}, "comment"=>"<p>More Stuff to test</p>"}]}, "can_reply"=>false}, {"blog_name"=>"testing", "id"=>116812932, "post_url"=>"http://testing.tumblr.com/post/116932942/testing-more-stuff", "slug"=>"testing-more-stuff", "type"=>"text", "date"=>"2015-04-19 13:08:10 GMT", "timestamp"=>142944889, "state"=>"published", "format"=>"html", "reblog_key"=>"3v46jji", "tags"=>[], "short_url"=>"http://tmblr.co/Z0lk1iob_TE", "followed"=>false, "highlighted"=>[], "liked"=>false, "note_count"=>1, "title"=>"Testing more stuff", "body"=>"<p>More Stuff to test</p>", "can_reply"=>false}, {"blog_name"=>"testing", "id"=>18128057, "post_url"=>"http://testing.tumblr.com/post/181257/erm-i-am-just-like-testing-this-thing", "slug"=>"erm-i-am-just-like-testing-this-thing", "type"=>"text", "date"=>"2015-04-19 13:07:16 GMT", "timestamp"=>142948836, "state"=>"published", "format"=>"html", "reblog_key"=>"gOGpGC", "tags"=>[], "short_url"=>"http://tmblr.co/Z09Ylk1boXP", "followed"=>false, "highlighted"=>[], "liked"=>false, "note_count"=>0, "title"=>"Erm, I am just like testing this thing", "body"=>"<p>well, let me test this.</p>", "can_reply"=>false}]
Is there a way for me to use this gem to query for "likes" of each individual posts from "mytumblr["posts"]"?
UPDATE
Tumblr.configure do |config|
config.consumer_key = ENV["TUMBLR_ID"]
config.consumer_secret = ENV["TUMBLR_SECRET"]
config.oauth_token = "#{oauth_access_token}"
config.oauth_token_secret = "#{oauth_password}"
end