Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upDirect Message API changes #1081
Comments
This comment has been minimized.
This comment has been minimized.
do-n-khanh
commented
Aug 16, 2018
|
twitter is going to shut down Direct Message API today. Is there any update? Thanks. |
This comment has been minimized.
This comment has been minimized.
j-e-d
commented
Aug 16, 2018
|
Update from Twiiter:
|
This comment has been minimized.
This comment has been minimized.
do-n-khanh
commented
Aug 17, 2018
•
|
Because I just need to send direct message, where is a quick fix for anyone who wants it right now: If you are on version 2.3.0 (like me), that is all you need. But if you are on version 3.6.0, then you need add 3 lines of code to binder.py (quick and dirty fix) You can send DM like:
|
This comment has been minimized.
This comment has been minimized.
StefTocup
commented
Aug 17, 2018
•
|
@do-n-khanh When I'm using your api.py over a 3.6.0 it doesn't work
try :
self.config = ConfigParser.ConfigParser()
self.config.read(os.path.expanduser('~/Prog/config/.twitterrc'))
consumer_key=self.config.get("security","consumer_key")
access_token=self.config.get("security", "access_token")
consumer_secret=self.config.get("security","consumer_secret")
access_token_secret=self.config.get("security","access_token_secret")
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
except ConfigParser.NoSectionError:
print("Section security non trouvée")
self.configT = ConfigParser.ConfigParser()
self.configT.read(os.path.expanduser('~/Prog/config/.TwittingDoor'))
try :
self.destname=self.configT.get("twitter","destname")
except ConfigParser.NoSectionError:
print("Section twitter non trouvée")
self.api = tweepy.API(auth)
self.send_direct_message(self.destname,"test")
def send_direct_message(self,dest, msg):
event = {
"event": {
"type": "message_create",
"message_create": {
"target": {
"recipient_id": dest
},
"message_data": {
"text": msg
}
}
}
}
self.api.send_direct_message_new(event)
|
This comment has been minimized.
This comment has been minimized.
do-n-khanh
commented
Aug 17, 2018
|
@StefTocup: Sorry, my version is 2.3.0. Let's me see how it works in 3.6.0 |
This comment has been minimized.
This comment has been minimized.
do-n-khanh
commented
Aug 17, 2018
|
@StefTocup: I made a dirty fix to make it work in 3.6.0 by adding 3 lines of code to binder.py Let's me know if it works for you. |
This comment has been minimized.
This comment has been minimized.
StefTocup
commented
Aug 17, 2018
|
@do-n-khanh it's working with this quick fix.
|
This comment has been minimized.
This comment has been minimized.
do-n-khanh
commented
Aug 17, 2018
|
yes, it is because twitter api only allow user id. |
Harmon758
referenced this issue
Aug 22, 2018
Open
StreamListener userstream 410 error (resource not found) #1092
This comment has been minimized.
This comment has been minimized.
ZeroCoolHacker
commented
Sep 19, 2018
|
It is not working. |
This comment has been minimized.
This comment has been minimized.
arturoabruzzini
commented
Sep 19, 2018
|
Hi, has anyone picked this up? Do we have an idea of when Tweepy will be migrated to the new API? |
This comment has been minimized.
This comment has been minimized.
do-n-khanh
commented
Sep 20, 2018
Please paste the error log. |
This comment has been minimized.
This comment has been minimized.
Exceen
commented
Sep 21, 2018
•
|
I'm using tweepy 3.6.0 and it doesn't work for me either. I added the lines from your commit do-n-khanh@c978749 and noticed that the path seems to be Printing
What I don't understand is how this should fix the problem. You're essentially removing the two important arguments to send a DM. But then again I didn't look into tweepy's code so I have 0 understanding of what tweepy does. I just seems quite weird and looks like you're not just preventing the error message but also the DM from being sent. Figured out that the path seems to have been changed to this. (https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/new-event) Now I just need to figure out how to modify the data tweepy sends so that the Twitter API properly understands my request. |
This comment has been minimized.
This comment has been minimized.
do-n-khanh
commented
Sep 21, 2018
•
|
Hi Exceen, it works for me (on 2.3.0 and 3.6.0) and @StefTocup (3.6.0) if you are on version 3.6.0, then you need:
To send DM, you need to use
Note that we are using send_direct_message_new. |
This comment has been minimized.
This comment has been minimized.
bakayim
commented
Sep 24, 2018
|
I fixed "get" part of DM. Waiting my pull request to be merged You can find pull request at: #1109 |
This comment has been minimized.
This comment has been minimized.
FdMon
commented
Sep 25, 2018
|
Hi do-n-khanh I´m on version 3.6.0. I added the 2 methods and the lines on binder.py but when I import tweepy this new funtion "send_direct_message_new" is not available. I get the error api object has no attribute "send_direct_message_new" I started to use tweepy and python a couple o months ago. Maybe i do something wrong. Thanks in advance for your help |
This comment has been minimized.
This comment has been minimized.
do-n-khanh
commented
Sep 25, 2018
|
what framework or environment are you working on? you need to make sure that the modified tweepy lib is called instead of the old one. and please make sure 2 methods are put in api.py file. lastly, you need to paste the error log so that i can figure out the error. |
This comment has been minimized.
This comment has been minimized.
FdMon
commented
Sep 25, 2018
|
do-n-khanh, your point. I had changed a old lib.... now it works fine!!! thanks a lot!!! |
This comment has been minimized.
This comment has been minimized.
huangweibuct
commented
Sep 28, 2018
|
Hi do-nkhanh, Have you met this error: "tweepy.error.TweepError: [{u'message': u'You cannot send messages to users who are not following you.', u'code': 150}]" I wanted to use send_direct_message_new to send message to some users who is not following me and whom I'm not following too. Any ideas? Thanks! |
This comment has been minimized.
This comment has been minimized.
do-n-khanh
commented
Sep 28, 2018
|
that is impossible due to twitter rules |
j-e-d commentedJul 20, 2018
•
edited
Twitter is deprecating some of it's REST API endpoints for Direct Messages on August 16, 2018 and replacing them with new endpoints that require changes in how data is sent, they will also return DMs with a different format. More details in the Direct Message Migration guide and in the announcement.
Edit: new reminder from twitter: https://twittercommunity.com/t/reminder-site-streams-user-streams-and-legacy-dm-endpoints-will-be-sunset-august-16th/109482