From f91da7cadf9d3ddeefd7e01b99622ad84fd14e88 Mon Sep 17 00:00:00 2001 From: Gage Coprivnicar Date: Sun, 12 Jun 2016 16:42:25 -0600 Subject: [PATCH] added get_direct_message example added a get_direct_message example hope this is helpful. I spent a lot of time trying to figure it out and figured I could help others with the same problem --- get_direct_message example | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 get_direct_message example diff --git a/get_direct_message example b/get_direct_message example new file mode 100644 index 0000000..5a27a06 --- /dev/null +++ b/get_direct_message example @@ -0,0 +1,17 @@ +from twython import Twython, TwythonError +twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET) + + +get_list = twitter.get_direct_messages() +#Returns All Twitter DM information which is a lot in a list format + +dm_dict = get_list[0] +#Sets get_list to a dictionary, the number in the list is the direct message retrieved +#That means that 0 is the most recent and n-1 is the last DM revieved. +#You can cycle through all the numbers and it will return the text and the sender id of each + +print dm_dict['text'] +#Gets the text from the dictionary + +print dm_dict['sender']['id'] +#Gets the ID of the sender