jgorset/facepy — pull request #43 by pylanglois (2012-06-08 05:18:51+00:00)
Title: Fixing issue in batch that prevent the code to end properly

Hi

I use the batch feature a lot and sometime facebook returns an invalid error that is not well formatted. When such error occurs, a KeyError exception on data['error'] is raised breaking the for loop unelegantly. This leads to a big loss of data when I use a big batch (50 requests with a limit=300 per request).

So I have patched the problem by checking if the error is well formatted or not. When it's not, I use an hardcoded message to prevent the exception to be raised. This is not elegant but it allows the code to end properly.

You can experience an invalid facebook error with this request:

7766361077_10150747658106078/comments?limit=300&offset=3000&__after_id=7766361077_10150747658106078_22084845

Thanks!

Pierre-Yves Langlois