使用Tweetsharp在Twitter帖子中显示百分号导致401 Unauthorized

时间:2013-02-05 16:11:02

标签: c# tweetsharp

我有一段发送推文的简单代码。保留带有%符号的消息会导致401 Unauthorized错误:

class Program
{
    static void Main(string[] args)
    {
        var test = new TwitterService("ConsumerKey", "ConsumerSecret", "Token", "TokenSecret");

        try
        {
            // "Test 1, So, I know there's no #inflation and so on...but the 10y inflation swap just went to 2.80%. 5y CPI 5y forward is 3.15%. Hmmm."
            test.SendTweet(WebUtility.HtmlEncode("Test 3, So, I know there's no #inflation and so on...but the 10y inflation swap just went to 2.80%. 5y CPI 5y forward is 3.15. Hmmm."));
        }
        catch (Exception ex)
        {
            if (ex.Message.Equals(""))
            {

            }
        }
    }
}

如果我通过TweetDeck发送相同的消息或直接使用Twitter页面,它发布没有问题。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

看起来您必须使用%而不是常规的%符号。