drone29a / clojure-twitter

Clojure client for Twitter API
BSD 2-Clause "Simplified" License
120 stars 33 forks source link

clojure-twitter seems to fail convert UTF-8 strings on posting #9

Closed tomykaira closed 13 years ago

tomykaira commented 13 years ago

The post of DM without URL encoding,

(twitter/with-oauth
    oauth-consumer
    oauth-access-token
    oauth-access-token-secret
    (twitter/send-direct-message-to-id my-id "こんにちは"))

it fails with the following error.

2011/10/30 2:22:11 org.apache.http.impl.client.DefaultRequestDirector handleResponse
Warning: Authentication error: Unable to respond to any of these challenges: {oauth=WWW-Authenticate: OAuth realm="http://api.twitter.com"}
twitter.proxy$java.lang.Exception$0: [401] Could not authenticate with OAuth.. [/1/direct_messages/new.json] (NO_SOURCE_FILE:0)

But when the string is apparently encoded,

(twitter/with-oauth
    oauth-consumer
    oauth-access-token
    oauth-access-token-secret
    (twitter/send-direct-message-to-id my-id (java.net.URLEncoder/encode "こんにちは" "UTF-8")))

it succeeds to post.

I saw the packet of POST request, and the text was "%3F%3F%3F%3F%3F%3F"... (this is a result of another UTF-8 string).

I suspect this is because the UTF-8 string is not properly converted in your library.

tomykaira commented 13 years ago

Sorry, this issue is not because of clojure-twitter or clj-oauth. https://github.com/rnewman/clj-apache-http/pull/10