facebookarchive / fbconsole

A micro api client for writing scripts against the Facebook Graph API.
Other
325 stars 74 forks source link

HTTP Error 400: Bad Request #5

Closed Cornchips closed 9 years ago

Cornchips commented 12 years ago

The post status function works in the morning but then fails later on in the day for me. Once it fails, deleting the access token wont fix it. The only way to fix it I found was waiting a few hours. The get friends function still works though.

Is this possibly the result of facebook banning the use of fbconsole on my account due to similar status updates?

pcardune commented 12 years ago

that is possible. You can catch the exception and print out some more information. I believe http errors have a read() method that will give you the body of the response, which generally has some more detailed information. Easier to use error handling should probably be built into fbconsole.

mutaku commented 12 years ago

One thing to check is that you have set your permissions before authenticating. I had forgotten to do that after removing fbconsole access to test something out.

This should give you a 403 though, but the first few times it gave me a 400 for some reason or another. The 403 I get if I try to post to a stream without invoking (fbconsole.AUTH_SCOPE = ['publish_stream', 'publish_checkins']) before authentication is something like :

    result = fbconsole.post('/me/feed', {'message':data})
  File "/usr/local/lib/python2.7/dist-packages/fbconsole-0.3-py2.7.egg/fbconsole.py", line 286, in post
    return json.load(urllib2.urlopen(request))
  File "/usr/lib/python2.7/urllib2.py", line 126, in urlopen
    return _opener.open(url, data, timeout)
  File "/usr/lib/python2.7/urllib2.py", line 397, in open
    response = meth(req, response)
  File "/usr/lib/python2.7/urllib2.py", line 510, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python2.7/urllib2.py", line 435, in error
    return self._call_chain(*args)
  File "/usr/lib/python2.7/urllib2.py", line 369, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 518, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 403: Forbidden

I mention this only because I would think you should be able to still access the friends list while not being able to post when not having set those scoping items.

alatyshev commented 12 years ago

Getting the same 'HTTP 400: Bad Request' error, after my script runs for awhile.

Catched the exception and HTTPError read() method gives the following: {"error":{"message":"(#341) Feed action request limit reached","type":"OAuthException","code":341}}

Found the following explanation for such error: "Based on the affinity users show for your apps use of Facebook Platform through their interactions, your app is allocated certain abilities and limits. This is the functionality currently allocated to your app. These values will change over time depending on how users interact with your app. All integration points have a set of limit values and the threshold bucket column tells you which of these limits buckets your app is in for that integration point. Bucket 1 is the smallest allocation bucket."

Paul, is it possible to increase these limits for 'fbconsole' ? ;)

pcardune commented 12 years ago

It's not possible to increase these limits for fbconsole. What you should probably do is create your own facebook app and use it's APP_ID instead of fbconsole's. Then you won't be affected by everyone else's use of the fbconsole app id.

In the master branch, these sorts of HTTPError exceptions are now being converted into OAuthExceptions with a more helpful error message. Hopefully I'll get to making another release with the improved exception handling soon.