inueni / birdy Goto Github PK
View Code? Open in Web Editor NEWA super awesome Twitter API client for Python.
License: MIT License
A super awesome Twitter API client for Python.
License: MIT License
_ssl.c:343: error:0B084002:x509 certificate routines:X509_load_cert_crl_file:system lib
This is the error I'm getting while making an executable file with pyinstaller. How do I turn of ssl verification?
Seems like Twitter API docs have moved, it be nice to have correct, working, links in there.
Hi,
On birdy/twitter.py line 233, you have a name error;
except request.RequestException as e:
Should be:
except requests.RequestException as e:
Kind regards.
Does Birdy support requests made to /1.1/statuses/sample.json or just /1.1/statuses/filter.json?
Trying out the following and I'm getting no data returned from stream(). It justs blocks indefinitely.
I'm using Python 3.5.2 on Windows 10.
client = StreamClient(CONSUMER_KEY,
CONSUMER_SECRET,
ACCESS_TOKEN,
ACCESS_TOKEN_SECRET)
resource = client.userstream.user.get()
print(resource)
for data in resource.stream():
print(data)
Great piece of work, thanks for birdy!
I am using twitter streaming with code much like:
resource = client.stream.statuses.filter.post(track='twitter')
for data in resource.stream():
print data
However, after a few days it crashes and I am not sure why. Any way to run with enhanced logging to capture the issue?
Birdy does not seem to be attaching headers to the exception object.
try:
response = self.client.api.search.tweets.get(**kwargs)
...
except TwitterRateLimitError, e:
# e.headers always seems to be None
...
e.headers always seems to be None.
Python 3.5
calling response.data.id resulted in an infinite recursion at line 117 of twitter.py
recursion appeared to be due to self.iterkeys() which appears to have been removed from python 3.5 (Not entirely sure why it doesn't just give an AttributeError). Replacement with self.keys seems to have resolved this.
https://github.com/inueni/birdy/blob/master/birdy/twitter.py#L266-L267
It would be nice to have the context of the triggering exception rerisen.
Dough Hellman on reraise exceptions:
http://doughellmann.com/2009/06/19/python-exception-handling-techniques.html
alternativly one could give the stacktrace of the inner exception to the new one.
Python 3 introduces raise … from …
I don't know what the python2 best practice to archive this behavior.
Not a URL.
Please.
Can you clarify the syntax to upload media?
I am trying to upload 4 images with one status update.
my code is
response = client.api['media/upload'].post(files[0])
the result is:
post() takes exactly 1 argument (2 given)
I am trying to upload the media and get the media ID back from twitter, do this 4 times total, then put a status update that connects to those 4 ids. This is my current understanding of how it should work (I might be wrong).
Step 1 is getting the syntax right in birdy to upload the media and get a return id.
Thank you.
What about Direct Message API?
It seems that the stream() is 1 post 'behind', is this supposed to be the case?
example:
response = client.stream.statuses.filter.post(track='@someperson')
for data in response.stream():
print data
if you now create a tweet on twitter:
@someperson testing 1
nothing will print
if you now create a second tweet on twitter:
@someperson testing 2
the data for the first tweet will now print out (@someperson testing 1)
if you create a third tweet:
@someperson testing 3
the data for the second tweet will now print out (@someperson testing2)
I'm trying a simple example for streaming API but I don't see anything but a blank screen and no output.
client = UserClient(CONSUMER_KEY,
CONSUMER_SECRET,
ACCESS_TOKEN,
ACCESS_TOKEN_SECRET)
response = client.stream.statuses.filter.post(track='love')
for data in response.stream():
print(data)
I am trying to do request on users/lookup route of Twitter API using params of Email/Phone. In the result I am getting error
Could not authenticate you. in response
While using the same credentials when i do request for screen_name, user_id lookup I am getting perfect Response. Not only that all other api requests like home_timeline, followers_ids, friends_ids, etc are working fine with same credentials but on that specific request, I am getting this error. My Request is:
import requests
url = "https://api.twitter.com/1.1/users/lookup.json?map=true&phone=1234567890"
payload = {}
headers = {
'Authorization': 'OAuth realm="http%3A%2F%2Fapi.twitter.com",oauth_consumer_key="<consumer_key>",oauth_token="<outh_token>",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1595318479",oauth_nonce="<nonce>",oauth_version="1.0",oauth_signature="<sig>"'
}
response = requests.request("GET", url, headers=headers, data = payload)
print(response.text.encode('utf8'))
In Response I am getting this Error:
{
"errors": [
{
"code": 32,
"message": "Could not authenticate you."
}
]
}
What are the reasons and suggestions on this ?
Will appreciate the positive feedback.
The tweets I get when using the SEARCH api are being "truncated" to 140 chars.
There is no iterkeys
method of dict
objects on Python 3.x, so __getattr__
falls into infinite recursion:
File ".../python3.4/site-packages/birdy/twitter.py", line 117, in __getattr__
if name in self.iterkeys():
RuntimeError: maximum recursion depth exceeded while calling a Python object
Yes, I see in the docs that Python 3.x is not officially supported. However, the library seems to work on it, and I hope this report will help you to add support of it.
client.api.users.lookup.get() request not working the request sent to servers is wrong for this case.
https://dev.twitter.com/rest/reference/get/users/lookup
I've followed the information in the Readme and installed birdy but am getting what looks like a parsing issue because the error appears on my variable for my Token Secret
my file
import sys
CONSUMER_KEY = KEY_VALUE
CONSUMER_SECRET = KEY_VALUE
ACCESS_TOKEN = KEY_VALUE
ACCESS_TOKEN_SECRET = KEY_VALUE
from birdy.twitter import StreamClient
client = StreamClient(CONSUMER_KEY,
CONSUMER_SECRET,
ACCESS_TOKEN,
ACCESS_TOKEN_SECRET)
resource = client.userstream.user.get()
for data in resource.stream():
print "Raw DATA ", data
This is the error I'm getting it seems that I'm missing something simple
python simple_user_streaming.py
File "simple_user_streaming.py", line 31
ACCESS_TOKEN_SECRET = KEY_VALUE
^
SyntaxError: invalid syntax
Line 143 in streaming branch: looks like method is undefined at that point
I'm attempting to follow other users from the UserClient but i'm getting:
birdy.twitter.TwitterAuthError: An unknown error has occured processing your request
I'm attempting to do this with:
u = user.api.friendships.create.post(screen_name='twitter',follow=True)
What am I doing wrong?
Account was cutoff and authentication disabled by Twitter trying to use the StreamClient.
Birdy successful creates a single instance of the StreamClient, and I get the response via this:
response = client.stream.statuses.filter.post(follow=users)
and then iterate the response:
for r in response.stream():
...
So, I would expect a single HTTP connection to happen. But, looking through my logs, I see a lot of these:
INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1)
It seems to me that there should not be a bunch of new HTTP connections. But looking at the requests docs, here: http://docs.python-requests.org/en/latest/user/advanced/ it looks like it is expected behavior to release a streaming connection back to the pool once the data is read off of the stream. So what I see is a handful of responses (tweets) followed by a reconnect, infinitely until Twitter cuts me off.
I don't see a way to tell requests to hold onto the connection rather than release it to the pool, so I'm not sure what is to be done about this.
May I know how to search tweets using the following API method
https://developer.twitter.com/en/docs/tweets/search/api-reference/get-search-tweets.html
Does birdy support Python 3? I looked through README and setup.py
and couldn't find any answer, other then Next release (0.3) will focus on Python 3 support
which created more questions (what release is this? it's not in GitHub releases, let's go to PyPI, etc.)
No matter the answer though (which I still don't 100% know ; ), it should be stated somewhere, ideally both in README and in setupy.py
classifiers.
In the POST example for a static update, the payload consists of simple key-value pairs:
status='Hello @pybirdy!'
I've successfully created a direct message using the deprecated direct_messages/new endpoint:
response = self.client.api.direct_messages.new.post(screen_name='cherdt', text='hello there')
I'm unclear how to accomplish the same using the direct_messages/events/new endpoint (https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/new-event).
I've tried creating a string representing the JSON, but I've been getting the following error:
birdy.twitter.TwitterApiError: Unable to decode JSON response.
Here's an example request I tried that produced the error:
response = self.client.api.direct_messages.events.new.post(event='{"type": "message_create", "message_create": {"target": {"recipient_id": "6039192"}, "message_data": {"text": "hi there"}}}')
Call to streaming api gets stuck and doesn't ever return. While others work.
from birdy.twitter import UserClient
CONSUMER_KEY = 'xxxx'
CONSUMER_SECRET = 'xxxx'
ACCESS_TOKEN = 'xxxxxxx'
ACCESS_TOKEN_SECRET = 'xxxx'
client = UserClient(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
response = client.stream.statuses.filter.post(track='python')
print "doesn't reach here"
for data in response.stream():
print data
JSONObject is not handled correctly by things like the pretty printer because of the repr override. This override seems unnecessary to me.
My general preference would be not to use JSONObject at all, but just to keep things simple by having the response handler return plain dictionaries. Barring that, it would be nice if the JSONObject was pretty printable by not overriding the repr.
I need to get the number of followers, number of friends etc. API just gives me first 20 one of them to see others, I have to use cursors. Or does birdy have another function?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.