我有一段简单的代码可以发送一条推文。保留带有 % 符号的消息会导致 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 页面发送相同的消息,它会毫无问题地发布。有任何想法吗?