How can I change/update the avatar and the background image using Ruby?
client = Twitter::REST::Client.new do |config|
config.consumer_key = "xxxxx"
config.consumer_secret = "xxxxx"
config.access_token = "xxxxx"
config.access_token_secret = "xxxxx"
end
The folder's name is "avis" ...it contains jpg files.
avis = Dir.entries("avis")
avi = avis.sample
puts client.update_profile_image(avi)
My response is:
rb:15:in `on_complete': media type unrecognized. (Twitter::Error::BadRequest)
Even if I put:
path = "/Users/.../avis"
file = File.open(path, "r")
file.each_line { |line|
puts line
}
f.close
My response is:
twitter.rb:819:in `each_line': Is a directory @ io_fillbuf - fd:10 /Users/,,,/Ruby/avis (Errno::EISDIR)
from twitter.rb:819:in `<main>'
have you followed the api docs? i can't see you encoding anything base64.
and what is that
'r'
inFile.read()
? are you mixing that up withFile.open()
?