0

我正在制作一个应用程序,我想在 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);

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

4

1 回答 1

1

您是否在您的应用程序中进行了身份验证?如果不是 facebook 会抛出一个错误。您需要一个身份验证 ID 才能在 Facebook 上发帖。

于 2012-08-26T09:42:08.403 回答