jugend/fgraph — Issue #13: Results from "comments" request are sometimes Arrays instead of Hashes
Author: bradical
Created: 2011-12-05 18:50:06+00:00
State: open

Hi, I've run into a strange issue that could be related to Facebook's Graph API or could be related to this gem.

Basically, when I make a request for a post's comments, sometimes I get a Hash and other times I seem to get an array. The code that makes the request and processes the comment is below.

The reason I know this is what's happening is that I'm getting an error on this line: `from = comment["from"]` about how I can't convert String to Fixnum so I'm assuming that the comment object is an indexed Array at that point.

def read_feed
client.object("#{self.facebook_page_id}/feed").each do |item|
next unless item.is_a?(Hash)
message = do_something_with_feed_item_hash(item)

client.object("#{item["id"]}/comments").each do |comment|
next unless comment.is_a?(Hash)
do_something_with_comment_hash(comment)
end
end
end

def do_something_with_comment_hash(comment)
from = comment["from"]
end