使用 RestFB 将视频上传到 Facebook

发布于 2024-10-17 00:23:56 字数 719 浏览 2 评论 0原文

我正在尝试使用 RestFB 上传视频,我尝试了 2 天,但仍然无法做到,有人可以帮助我吗? 我做了什么。

我知道我可以用这种方法上传视频 video.upload ,并且我必须向 Facebook 视频服务器发送请求,因此我创建了类 VideoLegacyFacebookClient,并将该服务器放在那里,我还尝试创建新的执行方法,该方法采用 InputStream binaryAttachement > 对于视频,并尝试编写此代码:

InputStream is=new DataInputStream(new FileInputStream(new File("/home/hagen/testing.avi")));
postId = facebookClient.execute("video.upload", null, String.class,is,
                    Parameter.with("title", "My Test Video"),
                    Parameter.with("description", "This is description"));

我做错了什么,有人可以帮助我吗?

I'm trying to upload video with RestFB, I tried do this for 2 days, but still can't do it, can somebody help me with this?
What I've done.

I know that I can upload video with this method video.upload, and I must send request to the Facebook video server, so I create class VideoLegacyFacebookClient, and put there this server, also I tried make new execute method, which take a InputStream binaryAttachement for video, and try to make this code:

InputStream is=new DataInputStream(new FileInputStream(new File("/home/hagen/testing.avi")));
postId = facebookClient.execute("video.upload", null, String.class,is,
                    Parameter.with("title", "My Test Video"),
                    Parameter.with("description", "This is description"));

What did I do wrong, can someone help me?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

就是爱搞怪 2024-10-24 00:23:56

RestFB 1.6.5 可能会修复这个问题; http://restfb.googlecode.com/svn/tags/restfb -project-1.6.5/CHANGELOG 说:

添加了对新视频上传 API 端点的支持
https://graph-video.facebook.com 并修复了多部分文件名错误
这破坏了视频上传。

RestFB 1.6.5 may fix this problem; http://restfb.googlecode.com/svn/tags/restfb-project-1.6.5/CHANGELOG says:

Added support for the new video upload API endpoint via
https://graph-video.facebook.com and fixed a multipart filename bug
that broke video uploads.

掩耳倾听 2024-10-24 00:23:56

关于视频上传的 Facebook How-tos 可能有用 https://developers.facebook.com/blog/帖子/493/

Facebook How-tos about video upload may be useful https://developers.facebook.com/blog/post/493/

猫七 2024-10-24 00:23:56

下面的代码片段将使用有效的应用程序访问令牌、应用程序密钥,

注意:将视频保存在资源/视频文件夹下。

上传到页面:

DefaultFacebookClient facebookClient = new DefaultFacebookClient(accessToken, appSecret, Version.LATEST);
facebookClient.publish(fbPageID + "/videos", GraphResponse.class, BinaryAttachment.with("videoName.mp4", IOUtils.toByteArray(getClass().getResourceAsStream("/video/videoName.mp4"))),
                    Parameter.with("description", " Video Description "));

Below Snippet will work with valid app access token, app secret,

Note: kept videos under resources/videos folder.

Uploading to a Page:

DefaultFacebookClient facebookClient = new DefaultFacebookClient(accessToken, appSecret, Version.LATEST);
facebookClient.publish(fbPageID + "/videos", GraphResponse.class, BinaryAttachment.with("videoName.mp4", IOUtils.toByteArray(getClass().getResourceAsStream("/video/videoName.mp4"))),
                    Parameter.with("description", " Video Description "));
羁绊已千年 2024-10-24 00:23:56
DataInputStream is =new DataInputStream(
new FileInputStream(new File("C:\\Users\\samiii\\Desktop\\rock.mp4")));
                fbClient.publish("me/videos", FacebookType.class,
                BinaryAttachment.with("rock.mp4", is),
                Parameter.with("title", "rock"),
                Parameter.with("description", "my first vid"));

试试这个,100%有效

DataInputStream is =new DataInputStream(
new FileInputStream(new File("C:\\Users\\samiii\\Desktop\\rock.mp4")));
                fbClient.publish("me/videos", FacebookType.class,
                BinaryAttachment.with("rock.mp4", is),
                Parameter.with("title", "rock"),
                Parameter.with("description", "my first vid"));

Try this one, it work 100%

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文