Skip to content

Commit

Permalink
added d method for sending direct messages (jnewland)
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.addictedtonew.com/public/gems/twitter@73 fe7eae16-9a24-0410-a59d-9e59979e88be
  • Loading branch information
jnunemaker committed Jun 22, 2007
1 parent 3025791 commit 139a820
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
0.1.2 - to be released soon
* implemented d method to send direct messages (jnewland)
* fixed since argument in direct_messages method (jnewland)
0.1.1 - May 20, 2007
* hpricot 0.5+ now supported; just a bug fix (Ryan Waldron is the man!)
Expand Down
23 changes: 11 additions & 12 deletions lib/twitter/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,17 @@ def direct_messages(since=nil)
(doc/:direct_message).inject([]) { |dms, dm| dms << DirectMessage.new_from_xml(dm); dms }
end

# This api methods doesn't seem to be working
# TODO: uncomment this when it is working
# def d(user, msg)
# url = URI.parse("http://#{@@api_url}/statuses/update.xml")
#
# req = Net::HTTP::Post.new(url.path)
# req.basic_auth(@config[:email], @config[:password])
# req.set_form_data({'user' => user, 'msg' => msg})
#
# response = Net::HTTP.new(url.host, url.port).start { |http| http.request(req) }
# puts response.message,response.body
# end
#Sends a direct message to <code>text</code> to <code>user</code>
def d(user, text)
url = URI.parse("http://#{@@api_url}/direct_messages/new.xml")
req = Net::HTTP::Post.new(url.path)

req.basic_auth(@config[:email], @config[:password])
req.set_form_data({'text' => text, 'user' => user})

response = Net::HTTP.new(url.host, url.port).start { |http| http.request(req) }
DirectMessage.new_from_xml(parse(response.body).at('direct_message'))
end

# Updates your twitter with whatever status string is passed in
def post(status)
Expand Down

0 comments on commit 139a820

Please sign in to comment.