p5-Facebook-OpenGraph icon indicating copy to clipboard operation
p5-Facebook-OpenGraph copied to clipboard

cannot access response headers for non-successful requests

Open sherrardb opened this issue 5 years ago • 2 comments

please forgive me if this has been addressed or covered elsewhere.

when encountering API limits, or other requests that result in a non-successful response, FB sometimes provides useful information in the response headers. in our specific case, we occasionally receive

4:- OAuthException:(#4) Application request limit reached
POST /v2.9/ HTTP/1.1
Connection: keep-alive
User-Agent: Facebook::OpenGraph/1.23
Authorization: OAuth ####################
Content-Type: application/x-www-form-urlencoded
Content-Length: 72
Host: graph.facebook.com

there should be a response header 'x-app-usage' that allows us to determine which limit we have exceeded

print $response->header('x-app-usage')."\n";
{"call_count":19,"total_cputime":0,"total_time":40}

but of course since the request method only returns the response object on is_success(), we cannot access that header.

of course i recognize that this is a complex issue from the perspective of the interface that you provide to the FB API, and that indicating failure while still providing access to structured data is not a straight-forward endeavor. my only thoughts as to possible approaches are the method used by DBI where additional error information is available through object and class variables

      $dbh = DBI->connect($data_source, $username, $password)
                or die $DBI::errstr;
      $dbh->commit or die $dbh->errstr;

thanks in advance for your consideration, and please let me know if i need to mock up a proper pull request, or provide further clarification.

sherrardb avatar Sep 11 '19 15:09 sherrardb

That's a reasonable request. Let me take a look at the current implementation and what can be done during this weekend.

oklahomer avatar Sep 13 '19 13:09 oklahomer

i know that this is a very old request, but i was just circling back to an internal ticket that depends on this and thought to check to see what you had discovered.

sherrardb avatar Dec 28 '21 17:12 sherrardb