How to send messages containing accents € and other special characters


#1

Hi,
I’m trying to use oauth to update messages on my account.
Everything looks good until I insert some non alphabetical characters in my message (ex. € à ì ù è… i think also character I must not use).
In these cases I obtain the message
{“errors”:[{“message”:“Could not authenticate you”,“code”:32}]}

I encode the message (status) with this function obtained googling:

    public String percentEncode(String string) {
        if (string == null) {
            return "";
        }
        try {
            return URLEncoder.encode(string, "UTF-8")
                    .replace("+", "%20").replace("*", "%2A")
                    .replace("%7E", "~");
        } catch (UnsupportedEncodingException wow) {
            throw new RuntimeException(wow.getMessage(), wow);
        }
    }

must I insert other characters in my function?
Where can I find a reference?

Simone Buzzi


#2

URL encode functions in standard libraries often have quirks that make them just slightly not compliant with this spec: http://tools.ietf.org/html/rfc3986

We’re very strict with that spec in API v1.1.

I would research your programming language and settle on a URL encode function that is more spec compliant and doesn’t require special cases.