bird-elephant
bird-elephant copied to clipboard
HTTP headers for Rate Limits
Hey!
When making requests to the Twitter API, they return headers as described here:
https://developer.twitter.com/en/docs/twitter-api/rate-limits
Note that the HTTP headers are contextual. When using application-only authentication, they indicate the rate limit for the application context. When using user-based authentication, they indicate the rate limit for that user context.
x-rate-limit-limit:
the rate limit ceiling for that given endpoint
x-rate-limit-remaining:
the number of requests left for the 15-minute window
x-rate-limit-reset:
the remaining window before the rate limit resets, in UTC epoch seconds
From what I understand, it's not possible to get these headers using BirdElephant, is that correct?
Thank you very much 😊
I added a line to print $request->getHeaders()
in Request.php
, around line 110, and I see the headers there:
["x-rate-limit-limit"]=>900
["x-rate-limit-reset"]=>1669337889
["x-rate-limit-remaining"]=>899
It would definitely be useful to be able to access these, after we make a request to Twitter API :)
Saving them to some private field and then some function like ->getLastCallHeaders()
.
Another suggestion is to rename $request
to $response
, just to be clear that what's returned into that variable is a Response :)