0

当我尝试从我的 android 应用程序将不同格式的视频(包括 .mp4 和 .3gp 文件)上传到 facebook 时,我在我的 facebook 帐户中收到一条通知,提示“无法处理您的视频。请访问视频帮助页面了解关于常见问题”。请帮助我。postToWall 功能将视频发布到 facebook。

    private void postToWall(String accessToken) {        
         String dataPath = "/mnt/sdcard/DCIM/Camera/video-2013-04-11-04-30-05.mp4";
         InputStream is = null;
         byte[] data = null;
         try {
            is = new FileInputStream(dataPath);
            data = readBytes(is);
        } catch (FileNotFoundException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } 
        Bundle params = new Bundle();   
        params.putString(Facebook.TOKEN, mFacebook.getAccessToken());              
        params.putString("filename", "Video_02.mp4");
        params.putByteArray("video", data);
        params.putString("contentType", "video/quicktime");
       params.putString("message", "video message");         
        mAsyncRunner.request("me/videos", params, "POST", new PostRequestListener(), null);
    }


               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();
    }
4

1 回答 1

2

这似乎是 Facebook API 或 SDK 的一个新的已知错误(今天的第一次报告)。

您可以在这里支持错误报告:http: //developers.facebook.com/bugs/543903808965945

于 2013-03-20T21:46:57.163 回答