Twitter上带有图像的推文中的问题 [英] Problem in Tweet on Twitter with an Image

查看:561
本文介绍了Twitter上带有图像的推文中的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我在我的项目中使用TweetSharp DLL在Twitter上发布带有简单文本的推文.现在,我要发布带有图像的推文...
我在用这个..

Currently I am using TweetSharp DLL in my project for posting tweets on Twitter with simple text. Now, I want to post a tweet with an image...
I am using this..

Hdn_FullPath.Value = "http://www.domain_name.com/images/Twitter/2015/2/user_icon.png";

#region "Tweet on Twitter"
var service = new TwitterService(DbConnect.ConsumerKey, DbConnect.ConsumerSecret);
service.AuthenticateWith(DbConnect.Token, DbConnect.TokenSecret);
TwitterStatus result;//= service.SendTweet(new SendTweetOptions { Status = txtPost.Text });

string URL_str = Hdn_FullPath.Value;//DbConnect.ShortenUrl(parameters.picture);

using (var stream = new FileStream(URL_str, FileMode.Open))
{
    result = service.SendTweetWithMedia(new SendTweetWithMediaOptions
    {
        Status = txtTweetDetails.Text.Trim(),
        Images = new Dictionary<string, Stream> { { URL_str, stream } }
    });
};

if (result == null)
    throw new NotImplementedException();
#endregion


但是在这种情况下,它将在第48行返回错误-
不支持URI格式.
说明:执行当前Web请求期间发生未处理的异常.请查看堆栈跟踪,以获取有关错误及其在代码中起源的详细信息.

异常详细信息:System.ArgumentException:不支持URI格式.


But in this case, it will return an error at line 48 -
URI formats are not supported.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: URI formats are not supported.

Line 46:         string URL_str = Hdn_FullPath.Value;//DbConnect.ShortenUrl(parameters.picture);
Line 47: 
Line 48:         using (var stream = new FileStream(URL_str, FileMode.Open))
Line 49:         {
Line 50:             result = service.SendTweetWithMedia(new SendTweetWithMediaOptions

推荐答案

您尝试转到图书馆文档 [
Did you try to go to the library documents[^], and look for the example yourself? If the API supports such function, developer already has shared the method and function to perform the action.

service.SendTweetWithMedia(new SendTweetWithMediaOptions 
                          { 
                               Status = "message", 
                               Images = dictionary 
                          });


通过使用
var stream1 = new FileStream(DbConnect.GetPhysicalPath + "\\Images\\Twitter\\2015\\2\\DSCN5670.jpg", FileMode.Open, FileAccess.Read);


这篇关于Twitter上带有图像的推文中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆