首页 文章

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

提问于
浏览
1

我目前正在开发一个ASP.NET MVC应用程序,它通过Graph API将Facebook用户的视频上传到Facebook . 视频上传到"//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( System.Dynamic.UpdateDelegates.UpdateAndExecute3 [T0,T1,T2,TRet]的字符串路径,对象参数)(CallSite站点,T0 arg0,T1 arg1,T2 arg2)...

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

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

提前致谢!

1 回答

  • 0

    我最终做的(在.NET SDK vs FB API v2.12中)与视频上传是一回事 - 我在ThumbType属性中放置了一个FacebookMediaStream(我假设FacebookMediaObject也可以工作),ContentType为“image / png” “和任何真正的文件名(”Thumb.png“?) .

    在其他语言/ SDK中应该有类似的方法,只需按照用于上传实际视频内容的相同过程 .

    这经历了,当我查看我的页面时,我看到缩略图是视频库中视频的默认缩略图 .

相关问题