1

I'm trying to get the count of shares from a Facebook page, but I can't seem to get the result out of the hash. Here's what I have:

y_response = @graph.get_connection('some_fb_page','posts',
                            {fields: ['message', 'id', 'from', 'type', 
'properties', 'link', 'shares', 'likes.summary(true)', 
 'comments.summary(true)', 'created_time', 'updated_time']
                            })

So y_response is Koala::Facebook::API::GraphCollection

y_response.each do |post|

and each of the post elements is a Hash

puts post["shares"]

gives me: {"count"=>3}

but

puts post["shares"]["count"]

gives an

undefined method `[]' for nil:NilClass (NoMethodError)

I've also tried

puts post["shares"][:count]
puts post["shares"][count]
puts post["shares"].count

for laughs.

What am I doing wrong? How do I get the count from the hash?

grooble
  • 617
  • 1
  • 8
  • 27

0 Answers0