lib/bird_grinder/tweeter.rb in birdgrinder-0.1.1.1 vs lib/bird_grinder/tweeter.rb in birdgrinder-0.1.2
- old
+ new
@@ -1,6 +1,7 @@
require 'uri'
+require 'cgi'
module BirdGrinder
# An asynchronous, delegate-based twitter client that uses
# em-http-request and yajl on the backend. It's built to be fast,
# minimal and easy to use.
@@ -55,11 +56,11 @@
# @param [Hash] opts extra options to pass in the query string
def follow(user, opts = {})
user = user.to_s.strip
logger.info "Following '#{user}'"
post("friendships/create.json", opts.merge(:screen_name => user)) do
- delegate.receive_message(:outgoing_follow, :user => user)
+ delegate.receive_message(:outgoing_follow, {:user => user}.to_nash)
end
end
# Tells the twitter api to unfollow a specific user
#
@@ -67,11 +68,11 @@
# @param [Hash] opts extra options to pass in the query string
def unfollow(user, opts = {})
user = user.to_s.strip
logger.info "Unfollowing '#{user}'"
post("friendships/destroy.json", opts.merge(:screen_name => user)) do
- delegate.receive_message(:outgoing_unfollow, :user => user)
+ delegate.receive_message(:outgoing_unfollow, {:user => user}.to_nash)
end
end
# Updates your current status on twitter with a specific message
#
@@ -93,11 +94,11 @@
def dm(user, text, opts = {})
text = text.to_s.strip
user = user.to_s.strip
logger.debug "DM'ing #{user}: #{text}"
post("direct_messages/new.json", opts.merge(:user => user, :text => text)) do
- delegate.receive_message(:outgoing_direct_message, :user => user, :text => text)
+ delegate.receive_message(:outgoing_direct_message, {:user => user, :text => text}.to_nash)
end
end
# Returns an instance of BirdGrinder::Tweeter::Streaming,
# used for accessing the alpha streaming api for twitter.
@@ -221,10 +222,10 @@
http
end
def post(path, params = {}, &blk)
real_params = {}
- params.each_pair { |k,v| real_params[URI.encode(k.to_s)] = URI.encode(v) }
+ params.each_pair { |k,v| real_params[CGI.escape(k.to_s)] = CGI.escape(v) }
http = request(path).post({
:head => {
'Authorization' => @auth_credentials,
'Content-Type' => 'application/x-www-form-urlencoded'
},
\ No newline at end of file