通过图形API将带有自定义缩略图的视频上传到Facebook



我目前正在开发一个 ASP.NET MVC应用程序,该应用程序通过Graph API将Facebook用户的视频上传到Facebook。视频上传到"/{user-id}/videos"路径工作正常,但是当我尝试通过将"thumb"参数添加到视频参数(https://developers.facebook.com/docs/graph-api/reference/user/videos/(来上传带有自定义缩略图的视频时:

dynamic videoParameters = new ExpandoObject();
videoParameters.source = new FacebookMediaObject()
{
ContentType = video.ContentType,
FileName = video.FileName,
}.SetValue(System.IO.File.ReadAllBytes(video.FilePath));
if (thumbnail != null)
{
videoParameters.thumb = thumbnail;
}
dynamic result = this.FacebookClient.Post("/me/videos", videoParameters);
return result;

抛出异常:

(OAuthException - #100( (#100( 图像格式无效。它应该是一个图像 文件数据。 at Facebook.FacebookClient.ProcessResponse(HttpHelper httpHelper, String responseString, Type resultType, Boolean containsEtag, IList'1 batchEtags( at Facebook.FacebookClient.Api(HttpMethod httpMethod, String path, Object parameters, Type resultType( at Facebook.FacebookClient.Post(字符串路径、对象参数( at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2( ...

我已经尝试将缩略图变量作为位图文件和 base64 字符串传递给"videoParameters.thumb"参数。由于在文档中写了:"要上传并与视频关联的视频缩略图原始数据",因此我还将缩略图作为字节数组传递。但在所有这些情况下,都会抛出上述异常。

经过长时间的研究,我仍然没有找到这个问题的解决方案。有人知道解决方案是什么吗?

提前感谢!

我最终所做的(在.NET SDK与FB API v2.12中(与视频上传相同 - 我在thumb属性中放置了一个FacebookMediaStream(我认为FacebookMediaObject也可以工作(,ContentType为"image/png"和任何真正("Thumb.png"?(。

其他语言/SDK 中应该有类似的方法,只需遵循您用于上传实际视频内容的相同过程即可。

这已经过去了,在查看我的页面时,我看到缩略图是视频库中视频的默认缩略图。

最新更新