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