难以在Facebook上发布视频

时间:2012-08-26 09:32:34

标签: android facebook

我正在制作一个应用程序,我想在facebook上粘贴视频。但每当我尝试时,我得到的是异常:

08-26 14:56:41.311: D/Facebook-Example(520): Response: {"error":{"message":"(#351) Video file was corrupt or invalid","type":"OAuthException","code":351}}
08-26 14:56:41.366: W/Facebook-Example(520): Facebook Error: (#351) Video file was corrupt or invalid

这是代码:

 mUploadButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                byte[] data = null;
                AssetFileDescriptor fileDesc = getResources().openRawResourceFd(
                R.raw.baba);
                String dataPath =  fileDesc.toString();//"android.resource://com.facebook.android/raw/movie";
                String dataMsg = "Your video description here.";
                String dataName = "baba.wav";

                Bundle param;
                AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(mFacebook);
                InputStream is ;
                try 
                {
                        is = fileDesc.createInputStream();
                    if(is != null)
                    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 SampleRequestListener(), null);
                }
                catch (FileNotFoundException e) {
                   e.printStackTrace();
                }
                catch (IOException e) {
                   e.printStackTrace();
                }       
            }
        });
        mUploadButton.setVisibility(mFacebook.isSessionValid() ?
                View.VISIBLE :
                View.INVISIBLE);

请告诉我如何解决这个问题。谢谢。

1 个答案:

答案 0 :(得分:1)

您是否在自己的应用中进行了身份验证?如果不是Facebook将抛出错误。您需要一个身份验证ID才能在Facebook上发布。