Closed happypeter closed 11 years ago
BTW. The code I am running is just the example dir of this repo and I had to
-gem 'time-ago-in-words'
+gem 'time_ago_in_words'
to make it work.
$ ruby -v
ruby 1.9.3p125
error with context
119.80.191.71 - - [02/May/2013 14:42:04] "POST /update " 302 - 1.9850
119.80.191.71 - - [02/May/2013 14:42:08] "GET / " 200 13582 4.2787
119.80.191.71 - - [02/May/2013 14:42:08] "GET /screen.css " 200 256 0.0017
119.80.191.71 - - [02/May/2013 14:42:09] "GET /favicon.ico " 404 18 0.0016
Encoding::CompatibilityError - incompatible character encodings: UTF-8 and US-ASCII:
^I/home/peter/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/weibo_2-0.1.1/lib/weibo_2/api/v2/base.rb:48:in `block in build_multipart_bodies'
^I/home/peter/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/weibo_2-0.1.1/lib/weibo_2/api/v2/base.rb:42:in `each'
^I/home/peter/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/weibo_2-0.1.1/lib/weibo_2/api/v2/base.rb:42:in `build_multipart_bodies'
^I/home/peter/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/weibo_2-0.1.1/lib/weibo_2/api/v2/statuses.rb:102:in `upload'
^I/home/peter/apps/weibo/example.rb:77:in `block in <top (required)>'
Hi, I am pretty sure it's because the example are using a older weibo_2 gem, I have fixed this issue, please pull the latest source to test, and thank you for mentioning gem time-ago-in-words has deprecated.
Just FYI, please remember to bundle update.
git pull
cd example
bundle update
Let me know the result, so I can close this issue. Thanks.
pulled down your lastest changes, do bundle update and restart the server, but NO LUCK, same error:
Encoding::CompatibilityError - incompatible character encodings: UTF-8 and US-ASCII:
^I/home/peter/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/weibo_2-0.1.2/lib/weibo_2/api/v2/base.rb:48:in `block in build_multipart_bodies'
except that you can see the 0.1.2
version of the gem is in use now.
I tried on 2.0.0-p0, 1.9.3-p374 and 1.9.3-p125, uploaded several images, not showing the error you are pointing out.
I reproduced this problem, the reason causing it is that this gem uses mime-type multipart/form-data to post pictures, and when building the post body, image file is binary while other parts are UTF-8.
I have fixed with this commit, https://github.com/simsicon/weibo_2/commit/c98afd48a5125d1da6b717ce4149addaf18c0650
Oh, by the way, I moved the example to here, try it out.
Thank you.
it worked! yeaaaaahhhhh...
A little problem:
there was a trailing string Content-Transfer-Encoding: binary
showed up after the status body I actually sent.
Yeah, working is cool.
The extra content-transfer-encoding is totally fine, I added it to satisfy http multipart post protocol.
Thanks.
@simsicon Thanks for your work.
But
content-transfer-encoding
is showed to all my audience, I don't think this is totally fine
I did not get what you mean, I made a mistake, and it's fixed now, sorry for this. Please run
bundle update weibo_2
Cool man, your fast response and kindness really get me impressed.
After connected with my weibo account, I could get my lastest status, I could send weibo in both English and Chinese. But, when I tried to attach a image, the above error showed up, and it's 100% reproducible.
Is this a bug? or am I missing sth? plz help.