2011-09-02 10 views
5

に私は次のコード動画をアップロードFacebookの

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); 

    } 

    } 

を使用して動画をFacebookにアップロードしようとしています。しかし、私は応答 {「エラー」で、次のエラーメッセージを取得しています:{「タイプ」:「OAuthException」、 "メッセージ": "(#352)ビデオファイル形式はサポートされていません"}}

誰か助けてくれますか?あなたの助けを前にありがとう。

+0

あなたはこれを見たことがありますか?http://stackoverflow.com/questions/10151708/upload-video-to-facebook-in-android/12470730#12470730 –

答えて

0

ビデオファイルに何か不具合がありますか? WMVはFacebookによってサポートされるべきですが、おそらくあなたは奇妙なWMVの変種、コピープロテクトされたものなどを使用していますか?別の動画で同じコードを試しましたか?

+0

ありがとう返信のため.....しかしそのビデオはtwitterのような他のサイトにアップロードされています... – Vishal

+0

私は確信していません。もしそれが間違いなく他の場所でうまく動作していて、ビデオに特別なものがなければ、Facebook側のビデ​​オアップロードのバグかもしれません。詳細なバグレポートを提出し、それを再現できるかどうか確認してください。 (http://bugs.developers.facebook.net/) – Igy

1

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

このリンクを参照してください私は、このリンクで言及されたすべてのものを試してみましたが、私はあなたと同じエラーを得ていました。 その後、私はFacebookのリファレンスプロジェクトをきれいにして、もう一度ビルドします。私の問題は解決されました。動画のアップロードが正常に行われています。

関連する問題