3
{
    Request request = null;
            RequestAsyncTask task = null ;

        Bundle requestParams    requestParams=new Bundle();
                        byte[] data = downloadUrl(new URL("urltodownload"));
                        requestParams.putByteArray("video", data);
                        requestParams.putString("title", "Video post");
                        requestParams.putString("description", " #SomeTag");
                        request = new Request(Session.getActiveSession(),"me/videos" , requestParams,
                                HttpMethod.POST,new Request.Callback() {
                            @Override
                            public void onCompleted(Response response) {
                                //appLink=null;
                                if (response.getError() == null) {
                                    Logs.e(DEBUG_FACEBOOK_PUBLISH, "publish success");
                                    if (uploadListener != null) {
                                        uploadListener.onSuccess(null);
                                    }
                                } else {
                                    Logs.e(DEBUG_FACEBOOK_PUBLISH, "publish error: "
                                            + response.getError().getErrorMessage());
                                    Logs.e(DEBUG_FACEBOOK_PUBLISH, "publish error: "
                                            + response.getError().toString());
                                    if (uploadListener != null) {
                                        uploadListener
                                        .onError("Facebook can't publish your content");
                                    }
                                }
                            }
                        });
                        task = new RequestAsyncTask(request);
                        task.execute(); 
                }   

private static byte[] downloadUrl(URL toDownload) {
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

        try {
            byte[] chunk = new byte[4096];
            int bytesRead;
            InputStream stream = toDownload.openStream();

            while ((bytesRead = stream.read(chunk)) > 0) {
                outputStream.write(chunk, 0, bytesRead);
            }

        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }

        return outputStream.toByteArray();
    }

{HttpStatus: 500, errorCode: 352, errorType: FacebookApiException, errorMessage: Sorry, the video file you selected is in a format that we don't support.}

I don't know what i am doing wrong but every time i got this error. is there any other method to post video to facebook wall. i know how to post video by newUploadVideoRequest method but in my case i don't want to download video and save it to sd card then post to facebook . There is other way i can call graph api url and post video to facebook wall but is there any other method so i can directly post video to facebook wall , I almost referes every link

Raj
  • 844
  • 2
  • 11
  • 29

1 Answers1

3

I just change

requestParams.putByteArray("video", data); to requestParams.putByteArray("video.3gp", data);

And it uploaded successfully you can try .mp4 also strange but there no helpful documentation regarding what should pass in parameters .Hope this is helpful

Raj
  • 844
  • 2
  • 11
  • 29