Ruby,更新推特头像和背景
Ruby, update twitter avatar and background
如何使用Rubychange/update头像和背景图片?
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
文件夹的名称是 "avis" ...它包含 jpg 文件。
avis = Dir.entries("avis")
avi = avis.sample
puts client.update_profile_image(avi)
我的回复是:
rb:15:in `on_complete': media type unrecognized. (Twitter::Error::BadRequest)
即使我放:
path = "/Users/.../avis"
file = File.open(path, "r")
file.each_line { |line|
puts line
}
f.close
我的回复是:
twitter.rb:819:in `each_line': Is a directory @ io_fillbuf - fd:10 /Users/,,,/Ruby/avis (Errno::EISDIR)
from twitter.rb:819:in `<main>'
您是否遵循了 api 文档?我看不到你在编码任何 base64。
The avatar image for the profile, base64-encoded. Must be a valid GIF, JPG, or PNG image of less than 700 kilobytes in size. Images with width larger than 400 pixels will be scaled down. Animated GIFs will be converted to a static GIF of the first frame, removing the animation.
File.read()
中的 'r'
是什么?你把它和 File.open()
混在一起了吗?
如何使用Rubychange/update头像和背景图片?
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
文件夹的名称是 "avis" ...它包含 jpg 文件。
avis = Dir.entries("avis")
avi = avis.sample
puts client.update_profile_image(avi)
我的回复是:
rb:15:in `on_complete': media type unrecognized. (Twitter::Error::BadRequest)
即使我放:
path = "/Users/.../avis"
file = File.open(path, "r")
file.each_line { |line|
puts line
}
f.close
我的回复是:
twitter.rb:819:in `each_line': Is a directory @ io_fillbuf - fd:10 /Users/,,,/Ruby/avis (Errno::EISDIR)
from twitter.rb:819:in `<main>'
您是否遵循了 api 文档?我看不到你在编码任何 base64。
The avatar image for the profile, base64-encoded. Must be a valid GIF, JPG, or PNG image of less than 700 kilobytes in size. Images with width larger than 400 pixels will be scaled down. Animated GIFs will be converted to a static GIF of the first frame, removing the animation.
File.read()
中的 'r'
是什么?你把它和 File.open()
混在一起了吗?