Upload video to Facebook, with RestFB
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", &qu开发者_JAVA技巧ot;My Test Video"),
Parameter.with("description", "This is description"));
What did I do wrong, can someone help me?
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.
Facebook How-tos about video upload may be useful https://developers.facebook.com/blog/post/493/
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 "));
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%
精彩评论