Perhaps this is already available somewhere and I just missed it in
the code.
I'm looking for a way to see the headers that Twitter sends back with
its response.
In particular, Twitter sends back X-RateLimit-* headers that would be
nice to see, as opposed to having to go back and send another
rate_limit_status request.
I've made a patch for my own copy of tweepy, which stores the headers
in the API object; however, I'm not sure if this model would work in
general, as it's not going to be thread-safe (and I'm not sure if the
rest of tweepy is threadsafe or not).
+ """ Return the first value of a header received from the last API
call. Return None if no such header. """
+ def header(self, header):
+ if self._headers.has_key(header):
+ return self._headers[header][0]
+ return None
+
+ """ Return the list of values of a header received from the last
API call. Return None if no such header. """
+ def headers(self, header):
+ if self._headers.has_key(header):
+ return self._headers[header]
+ return None
+
""" Internal use only """
@staticmethod
def _pack_image(filename, max_size):
On Friday, July 23, 2010 6:20:26 AM UTC-7, Johnson Earls wrote:
> Hello,
> Perhaps this is already available somewhere and I just missed it in > the code.
> I'm looking for a way to see the headers that Twitter sends back with > its response.
> In particular, Twitter sends back X-RateLimit-* headers that would be > nice to see, as opposed to having to go back and send another > rate_limit_status request.
> I've made a patch for my own copy of tweepy, which stores the headers > in the API object; however, I'm not sure if this model would work in > general, as it's not going to be thread-safe (and I'm not sure if the > rest of tweepy is threadsafe or not).
> + """ Return the first value of a header received from the last API > call. Return None if no such header. """ > + def header(self, header): > + if self._headers.has_key(header): > + return self._headers[header][0] > + return None > + > + """ Return the list of values of a header received from the last > API call. Return None if no such header. """ > + def headers(self, header): > + if self._headers.has_key(header): > + return self._headers[header] > + return None > + > """ Internal use only """ > @staticmethod > def _pack_image(filename, max_size):
And, after further digging, it appears that the GET search API does not return these headers. They are only available in the streaming or other APIs linked to an account/application if I'm interpreting the materials correctly.
On Monday, August 27, 2012 5:47:04 PM UTC-7, inactivist wrote:
> *bump*
> I'd like to know if this is possible as well. Specifically, when using > the GET search API.
> On Friday, July 23, 2010 6:20:26 AM UTC-7, Johnson Earls wrote:
>> Hello,
>> Perhaps this is already available somewhere and I just missed it in >> the code.
>> I'm looking for a way to see the headers that Twitter sends back with >> its response.
>> In particular, Twitter sends back X-RateLimit-* headers that would be >> nice to see, as opposed to having to go back and send another >> rate_limit_status request.
>> I've made a patch for my own copy of tweepy, which stores the headers >> in the API object; however, I'm not sure if this model would work in >> general, as it's not going to be thread-safe (and I'm not sure if the >> rest of tweepy is threadsafe or not).
>> + """ Return the first value of a header received from the last API >> call. Return None if no such header. """ >> + def header(self, header): >> + if self._headers.has_key(header): >> + return self._headers[header][0] >> + return None >> + >> + """ Return the list of values of a header received from the last >> API call. Return None if no such header. """ >> + def headers(self, header): >> + if self._headers.has_key(header): >> + return self._headers[header] >> + return None >> + >> """ Internal use only """ >> @staticmethod >> def _pack_image(filename, max_size):