我对 SendTweetWithMedia() 有疑问。这是我实施的方式
var service = new TwitterService(TwitterSettings.ConsumerKey, TwitterSettings.ConsumerSecret);
service.AuthenticateWith(twitterAccess.AccessToken, twitterAccess.AccessTokenSecret);
string status = string.IsNullOrEmpty(message) ? " " : message;
var memoryStream = new MemoryStream();
bitmap.SaveJpeg(memoryStream, bitmap.PixelWidth, bitmap.PixelHeight, 0, 100);
memoryStream.Position = 0;
var options = new SendTweetWithMediaOptions
{
Status = status,
Images = new Dictionary<string, Stream> {{"picture", memoryStream}}
};
service.SendTweetWithMedia(options, (responseStatus, response) => Dispatcher.BeginInvoke(() =>
{
memoryStream.Close();
memoryStream.Dispose();
if (response.StatusCode == HttpStatusCode.OK)
{
UiHelper.ShowToastPrompt(AppResources.TwitterToastPrompt);
}
else if (response.StatusCode == HttpStatusCode.Unauthorized)
{
NavigationService.Navigate(new Uri("/TwitterLoginPage.xaml", UriKind.Relative));
}
else
{
MessageBox.Show(response.StatusDescription, AppResources.ErrorMessageBoxCaption, MessageBoxButton.OK);
}
}));
但它在消息框中显示“禁止”。
即使我试图从 SendTweetWithMediaOptions 中删除图像,但它没有帮助。
任何人都可以帮忙吗?谢谢。