Windows phone 无法在windows phone中使用SendTweetWithMediaOptions
我在Windows Phone项目中使用TweetSharp,无论我做什么,我都不能在媒体上发布推文 我得到了异常195:缺少或无效参数 我了解到,通常这可能是无效数据的原因,就像我提供的流无效一样 我尝试过其他方法,但没有任何效果,我得到同样的例外 共享代码简化如下: MediaLibrary=新的MediaLibrary()Windows phone 无法在windows phone中使用SendTweetWithMediaOptions,windows-phone,tweetsharp,Windows Phone,Tweetsharp,我在Windows Phone项目中使用TweetSharp,无论我做什么,我都不能在媒体上发布推文 我得到了异常195:缺少或无效参数 我了解到,通常这可能是无效数据的原因,就像我提供的流无效一样 我尝试过其他方法,但没有任何效果,我得到同样的例外 共享代码简化如下: MediaLibrary=新的MediaLibrary() var picture=library.Pictures[0]; var options=新的SendTweetWithMediaOptions { Images=新字
var picture=library.Pictures[0];
var options=新的SendTweetWithMediaOptions
{
Images=新字典{{picture.Name,picture.GetImage()},
状态=TweetTextBox.Text,
};
AutentificateTwitterService().SendTweetWithMedia(选项,(状态,响应)=>
_dispatcher.BeginInvoke(()=>
{
DonePosting();
if(response.StatusCode==HttpStatusCode.OK)
{
_lastPostId=status.Id;
}
其他的
{
MessageBox.Show(String.Format(
“向Twitter{0}{1}发送图像时出错”,
环境,新线,
响应(错误);
}
}));
我试着与linqtotwitter分享,并进行了工作,但TweetSharp更适合我的项目。经过一段时间后,我终于发现了这方面的问题,我肯定还会遇到其他更多与WP和SendTweetWithMediaOptions相关的问题 问题是,如果你像现在这样深入研究SendTweetWithMedia,你将访问TwitterService.cs,其中将调用WithHammock,只是图像没有作为参数传递,因此它们会在那里丢失:) 我通过传递参数并添加
private void WithHammock<T>(WebMethod method, Action<T, TwitterResponse> action, string path, IDictionary<string, Stream> files, params object[] segments) where T : class
{
var url = ResolveUrlSegments(path, segments.ToList());
var request = PrepareHammockQuery(url);
request.Method = method;
request.QueryHandling = QueryHandling.AppendToParameters;
foreach (var file in files)
{
request.AddFile("media[]", file.Key, file.Value);
}
WithHammockImpl(request, action);
}
private void with hammock(WebMethod方法、Action操作、字符串路径、IDictionary文件、params object[]段),其中T:class
{
var url=ResolveUrlSegments(路径,segments.ToList());
var请求=PrepareHammockQuery(url);
request.Method=Method;
request.QueryHandling=QueryHandling.AppendToParameters;
foreach(文件中的var文件)
{
request.AddFile(“媒体[]”,file.Key,file.Value);
}
使用hammockimpl(请求、操作);
}
我会试着看看我是否能把它拉出来,这样其他人都能得到这个修复
希望这有帮助
private void WithHammock<T>(WebMethod method, Action<T, TwitterResponse> action, string path, IDictionary<string, Stream> files, params object[] segments) where T : class
{
var url = ResolveUrlSegments(path, segments.ToList());
var request = PrepareHammockQuery(url);
request.Method = method;
request.QueryHandling = QueryHandling.AppendToParameters;
foreach (var file in files)
{
request.AddFile("media[]", file.Key, file.Value);
}
WithHammockImpl(request, action);
}