0

I want to post video to facebook wall can any one suggest me how to do that. I tried with the following code but it is not working. please provide some sample code if possible i successfully post the image and message on the wall but i unable to post the video. i have been struggling per the past two days but no use.This is my sample code

private void postToFacebook() { 
    mProgress.setMessage("Posting ...");
    mProgress.show();
    byte[] data = null;
    InputStream is = null; 
    try{
    is = new FileInputStream("/mnt/sdcard/DCIM/100MEDIA/VIDEO0001.3gp");   
    data = readBytes(is); 
    }catch(Exception e){}
    AsyncFacebookRunner mAsyncFbRunner = new AsyncFacebookRunner(mFacebook);

    Bundle params = new Bundle();

    params.putString("message","Some message");
    params.putString("name", "Dexter");
    params.putString("caption", "londatiga.net");
params.putString("description", "Dexter, seven years old dachshund who loves to catch cats, eat carrot and krupuk");
            params.putByteArray("video", data); 
mAsyncFbRunner.request("me/videos", params, "POST", new WallPostListener());
}
  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    
          MyByteArrayOutputStream byteBuffer = new MyByteArrayOutputStream();

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

private final class WallPostListener extends BaseRequestListener {
    public void onComplete(final String response) {
        mRunOnUi.post(new Runnable() {
            @Override
            public void run() {
                mProgress.cancel();

                Toast.makeText(TestPost.this, "Posted to Facebook", Toast.LENGTH_SHORT).show();
            }
        });
raju
  • 1,254
  • 13
  • 18
  • http://stackoverflow.com/questions/7156886/share-video-on-facebook-through-my-android-app see this – Abhi Dec 07 '11 at 15:02
  • HI Venky no error found in log cat after a long time oncomplete listener will be executed but video is not uploaded on to facebook wall – raju Dec 08 '11 at 11:51
  • possible duplicate of [Is uploading videos from an SD Card to Facebook possible with the Facebook SDK?](http://stackoverflow.com/questions/6908413/is-uploading-videos-from-an-sd-card-to-facebook-possible-with-the-facebook-sdk) – Juicy Scripter Feb 12 '12 at 17:50

0 Answers0