1 # = Messaging API Examples
3 # gem('twitter4r', '0.2.0')
6 # The following is only required if you want to use some configuration
7 # helper methods like <tt>Twitte4R::Client.from_config</tt> for
8 # sensitive/instance context.
9 # require 'twitter/console'
10 # config_file = File.join(File.dirname(__FILE__), '..', 'config', 'twitter.yml')
12 # To override client connection configuration please refer to
13 # the {<tt>configure.rb</tt>}[file:configure_rb.html] example code.
14 # twitter = Twitter::Client.from_config(config_file)
16 # To retrieve a list of direct messages received by the authenticated user
17 # you may do the following:
18 # messages = twitter.messages(:received)
20 # To retrieve a list of direct messages sent by the authenticated user
21 # you may do the following:
22 # messages = twitter.messages(:sent)
24 # To send a direct message to another user, you can do the following:
25 # text = 'Do you want to meet me at our favorite coffeeshop at 3pm?'
26 # message = twitter.message(:post, text, 'myfriend')
27 # As with most methods that accept the user's screen name you can also use in
28 # it's place either the unique integer user ID or the <tt>Twitter::User</tt>
29 # object representation of the desired recipient user. For example,
30 # friend = Twitter::User.find('myfriend', twitter)
31 # message = twitter.message(:post, text, friend)
33 # message = twitter.message(:post, text, friend.id)
35 # To delete a direct message you can use the following code:
36 # twitter.message(:delete, message)
37 # You may also pass in the unique integer message ID instead like:
38 # twitter.message(:delete, message.id)