nov / fb_graph

This gem doesn't support FB Graph API v2.0+. Please use fb_graph2 gem instead.
MIT License
1.04k stars 191 forks source link

TypeError: can't convert Symbol into Integer when pulling "home" feed for a FbGraph::User #310

Closed weyus closed 11 years ago

weyus commented 11 years ago

Given that "sean.facebook_user" (in my app) is a FbGraph::User, if I issue

sean.facebook_user.send(:home, options)

I get:

TypeError: can't convert Symbol into Integer
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p290@redflag/gems/fb_graph-2.6.5/lib/fb_graph/location.rb:9:in `[]'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p290@redflag/gems/fb_graph-2.6.5/lib/fb_graph/location.rb:9:in `initialize'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p290@redflag/gems/fb_graph-2.6.5/lib/fb_graph/venue.rb:6:in `initialize'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p290@redflag/gems/fb_graph-2.6.5/lib/fb_graph/page/category_attributes.rb:110:in `new'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p290@redflag/gems/fb_graph-2.6.5/lib/fb_graph/page/category_attributes.rb:110:in `initialize_with_category_specific_attributes'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p290@redflag/gems/fb_graph-2.6.5/lib/fb_graph/post.rb:109:in `new'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p290@redflag/gems/fb_graph-2.6.5/lib/fb_graph/post.rb:109:in `initialize'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p290@redflag/gems/fb_graph-2.6.5/lib/fb_graph/connections/home.rb:7:in `new'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p290@redflag/gems/fb_graph-2.6.5/lib/fb_graph/connections/home.rb:7:in `block in home'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p290@redflag/gems/fb_graph-2.6.5/lib/fb_graph/connections/home.rb:6:in `map!'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p290@redflag/gems/fb_graph-2.6.5/lib/fb_graph/connections/home.rb:6:in `home'

Looks like when you get the posts for the home feed, if they have a "place" attribute that is a Hash, then it is not being handled correctly.

This appears to be similar to Issue 231 which resulted in Todo 232. Should I attempt to use the workaround described in the ToDo?

nov commented 11 years ago

Could you send me the actual JSON response?

weyus commented 11 years ago

Sure. From which call do you want it - the call to the home feed, I assume?

nov commented 11 years ago

Yeah, home feed.

I'm assuming FB returns a location in a place in a post as an JSON String, not as an JSON Object containing latitude, longitude and country. (as described in the below document) https://developers.facebook.com/docs/reference/api/post/

So I want to know how/why such data is generated and whether I need parse it or just omit it.

If you could find such "undocumented" format of location data in your GET /me/home?access_token=** response, that exact one line is also enough.

weyus commented 11 years ago

Here's the the relevant part of the post that fails on this user - just like you said, the location inside the place is a string. I suspect that this is the first post that has a "place" attribute in this particular home feed.

"place"=>{"id"=>"462904087116641", "name"=>"Phi Psi Woodstock's Fundraiser!", "location"=>"Woodstock's Pizza San Diego", "start_time"=>"2013-04-10T17:00:00-0700"}, 
nov commented 11 years ago

Are you still getting the error? I just made a post with "non-structured" location tag, but get no location data in the post via Graph API. https://www.facebook.com/matake/posts/10151584232307277

FB might already fixed (or just turned-off) such non-structured location data.

{
  "id": "579612276_10151584232307277", 
  "from": {
    "name": "Nov Matake", 
    "id": "579612276"
  }, 
  "message": "test test", 
  "actions": [
    {
      "name": "Comment", 
      "link": "https://www.facebook.com/579612276/posts/10151584232307277"
    }, 
    {
      "name": "Like", 
      "link": "https://www.facebook.com/579612276/posts/10151584232307277"
    }
  ], 
  "privacy": {
    "description": "Public", 
    "value": "EVERYONE", 
    "friends": "", 
    "networks": "", 
    "allow": "", 
    "deny": ""
  }, 
  "type": "status", 
  "status_type": "mobile_status_update", 
  "created_time": "2013-04-15T09:42:22+0000", 
  "updated_time": "2013-04-15T09:42:22+0000", 
  "comments": {
    "count": 0
  }
}

If you still getting the error, I'll allow simple string location.

weyus commented 11 years ago

I got it to happen on the same user, but this time it failed on a different post. Same format for the :place key, though:

"place"=>{"id"=>"237900519680678", "name"=>"MuirSkate's Downhill Disco (2013)", "location"=>"Cara Way, San Diego, CA", "start_time"=>"2013-04-12T18:00:00-0700"}

I looked at this post in the Graph API Explorer, and the story was of the format:

""story": "X was tagged in Y's photo."

so it's not a regular status update.

tony612 commented 11 years ago

I also run into this problem, hasn't it be fixed? I think it was caused by different version of facebook. You can see the old user page: http://www.facebook.com/coldplay/info. But I wonder why not its api reference explain it?

nov commented 11 years ago

Hopefully, I can take a few hours to debug the issue in this evening..

I'm guessing story is not post but another object type.

nov commented 11 years ago

Hum, I can make story type of post by tagging photos etc. However, even I attached a location to the post with "just use ***" option, graph api doesn't return location data. If I attached structured location (as a FB page), graph api returns it.

Maybe they have some internal bug in some cases, I guess. For now, I just ignore the non-structured location data in graph api response. (I don't think such location data is what you want)

nov commented 11 years ago

Just released v2.6.7 with the fix. Please try it.

tony612 commented 11 years ago

cool, I'll try it :)

tony612 commented 11 years ago

It seems that the hometown problem hasn't been fixed?

nov commented 11 years ago

hometown problem? maybe it's different issue?

tony612 commented 11 years ago

this issue? https://github.com/nov/fb_graph/issues/231 or https://github.com/nov/fb_graph/issues/232 I think hometown has the similar problem.

weyus commented 11 years ago

Perhaps the source of the story is the issue - a mobile FB client?