1

I'm trying to post a video in facebook through my android application. But I can't finish that. There is no error in Logcat. Adding my code below.

private void PostVdoFacebook(String review){
      mProgress.setMessage("Posting ...");
      mProgress.show();
      String response=" ";
      AsyncFacebookRunner mAsyncFbRunner = new AsyncFacebookRunner(mFacebook);
      FileInputStream is;
      Bundle params = new Bundle();
      try{
       is = new FileInputStream(getRealPathFromURI(uriVideo));
       byte[] data = readBytes(is);

      params.putByteArray("video",
        data);

     } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
     }
      params.putString("caption", review);
      mAsyncFbRunner.request("me/videos", params, "POST",
                 new PhotoUploadListener());
     }

and the readBytes function is

 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();
  }
ASP
  • 1,974
  • 3
  • 18
  • 30
  • 1
    you are using a `PhotoUploadListener`, what is happening there? did you debug there? try going step by step – thepoosh May 22 '12 at 06:19
  • 1
    @Thepoosh hi.. got response, that says " response is {"error":{"message":"(#352) Video file format is not supported","type":"OAuthException","code":352}}" – ASP May 22 '12 at 06:44
  • well, I guess this gives you an answer – thepoosh May 22 '12 at 06:55
  • 1
    Solved... dont know how.. I just replaced Util.java in com.facebook.android package. got Util.java from here https://raw.github.com/johnmph/facebook-android-sdk/d0e6ca9d3ecfbe964e72803fdd340cfeafa6ee2e/facebook/src/com/facebook/android/Util.java – ASP May 22 '12 at 10:13
  • @Thepoosh anyway, thnx for ur help :) – ASP May 22 '12 at 10:14
  • have u try with video url or from sdcard – Khan Jun 30 '12 at 12:48
  • 1
    Getting the same error "10-09 17:47:19.474: D/Uploading the Video...(12079): Response: {"error":{"message":"(#352) Video file format is not supported","type":"OAuthException","code":352}}" – Rahul Upadhyay Oct 09 '12 at 12:20
  • Please my answer here as i got success to post Video on FB: http://stackoverflow.com/questions/10151708/upload-video-to-facebook-in-android/12470730#12470730 – Shreyash Mahajan Dec 28 '12 at 05:40

0 Answers0