将视频上传到Facebook

编程入门 行业动态 更新时间:2024-10-08 05:22:13
本文介绍了将视频上传到Facebook的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试使用以下代码向Facebook上传视频

I am trying to upload video to facebook using the following code

public void uploadVideosFacebook(String videoPath) { byte[] data = null; String dataMsg = "Your video description here."; String dataName="Mobile.wmv"; Bundle param; AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(API); InputStream is = null; try { is = new FileInputStream(videoPath); data = readBytes(is); param = new Bundle(); param.putString("message", dataMsg); param.putString("filename", dataName); param.putByteArray("video", data); mAsyncRunner.request("me/videos", param, "POST", new fbRequestListener(), null); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } public byte[] readBytes(InputStream inputStream) throws IOException { // this dynamically extends to take the bytes you read ByteArrayOutputStream byteBuffer = new ByteArrayOutputStream(); // this is storage overwritten on each iteration with bytes int bufferSize = 1024; byte[] buffer = new byte[bufferSize]; // we need to know how may bytes were read to write them to the byteBuffer int len = 0; while ((len = inputStream.read(buffer)) != -1) { byteBuffer.write(buffer, 0, len); } // and then we can return your byte array. return byteBuffer.toByteArray(); } public class fbRequestListener implements RequestListener { @Override public void onComplete(String response, Object state) { // TODO Auto-generated method stub Log.d("RESPONSE",""+response); } @Override public void onIOException(IOException e, Object state) { // TODO Auto-generated method stub Log.d("RESPONSE",""+e); } @Override public void onFileNotFoundException(FileNotFoundException e, Object state) { // TODO Auto-generated method stub Log.d("RESPONSE",""+e); } @Override public void onMalformedURLException(MalformedURLException e, Object state) { // TODO Auto-generated method stub } @Override public void onFacebookError(FacebookError e, Object state) { // TODO Auto-generated method stub Log.d("RESPONSE",""+e); } }

但是我获取以下错误消息回复 {error:{type:OAuthException,message:(#352)不支持视频文件格式}}

But i am getting following error message in response {"error":{"type":"OAuthException","message":"(#352) Video file format is not supported"}}

任何人都可以帮助我。感谢您的帮助。

Can anyone help me out. Thanks in advance for your help.

推荐答案

查看此链接使用Facebook SDK将视频从SD卡上传到Facebook?

see this link Is uploading videos from an SD Card to Facebook possible with the Facebook SDK?

我尝试了这个链接中提到的所有内容,但是我遇到了与您相同的错误。 然后我清理Facebook参考项目并重新构建。我的问题已经解决了。视频上传正在工作。

i tried all stuff that was mention in this link but i was getting same error as you. then i clean Facebook reference project and build it again. and my prob was solved.now video uploading is working..

更多推荐

将视频上传到Facebook

本文发布于:2023-11-26 18:46:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1634751.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:视频   Facebook

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!