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

Screwy Facebook Response #355

Closed kenips closed 10 years ago

kenips commented 10 years ago

Hey @nov, here's another screwy Facebook response. Not sure if we're making too many calls, but sometimes Facebook would just completely throw up and return HTML even though we're asking for JSON (through fb_graph). The result is that you get something like this:

FbGraph::Exception: Unparsable Response: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" id="facebook">
<head> <title>Facebook | Error</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<meta http-equiv="Cache-Control" content="no-cache" />
 <meta name="robots" content="noindex,nofollow" />
 <style type="text/css"> html, body { margin: 0px; padding: 0px; text-align: center; font-family: "Lucida Grande", "Tahoma", "Verdana", "Arial", sans-serif; color: #333333; } a.menu ...nt-size: 11px; } </style> 
<script type="text/javascript" charset="utf-8"> function back() { if (1 < history.length) { history.back(); return false; } return true; } </script> </head>
 <body> <a class="menu" href="http://www.facebook.com/"></a> <div class="core"> <h1>Sorry, something went wrong.</h1>
 <p>We're working on getting this fixed as soon as we can.</p> <p><a onclick="return back();" href="http://www.facebook.com/">Go Back</a></p>
 <div class="footer" id="pagefooter_copyright"> Facebook &copy; 2013 &#183;
 <a href="http://www.facebook.com/help/">Help</a> </div> </div>
 </body> </html>

Trace:

/vendor/bundle/jruby/1.9/bundler/gems/fb_graph-f726ffccaa78/lib/fb_graph/node.rb:159 in "handle_response"
/vendor/bundle/jruby/1.9/bundler/gems/fb_graph-f726ffccaa78/lib/fb_graph/node.rb:155 in "handle_response"
/vendor/bundle/jruby/1.9/bundler/gems/fb_graph-f726ffccaa78/lib/fb_graph/node.rb:49 in "get"
/vendor/bundle/jruby/1.9/bundler/gems/fb_graph-f726ffccaa78/lib/fb_graph/searchable.rb:6 in "search"
/vendor/bundle/jruby/1.9/bundler/gems/fb_graph-f726ffccaa78/lib/fb_graph/searchable.rb:15 in "search"

Do you think fb_graph should handle this or leave as is?

nov commented 10 years ago

Hum, this is first time for me to see such kind of errors. I don't have any other idea rather than returning FbGraph::Exception in this case..