使用图形API在Facebook粉丝页面上传视频时出错

时间:2015-02-12 04:29:52

标签: facebook facebook-graph-api android-facebook facebook-graph-api-v2.2

我有一个Android应用程序,我需要将视频从我的应用程序上传到Facebook粉丝页面。

我成功发布图片但无法上传视频。 它总是给出错误响应,如: {响应:responseCode:400,graphObject:null,错误:{HttpStatus:400,errorCode:352,errorType:OAuthException,errorMessage:(#352)抱歉,您选择的视频文件格式为“我们不” t支持。},isFromCache:false}

我尝试上传不同的格式,如3gp,mp4等,但没有运气!

我为上传图片做了什么

             Bitmap photo = BitmapFactory.decodeResource(getResources(),R.drawable.in); 

            ByteArrayOutputStream stream = new ByteArrayOutputStream();
            photo.compress(Bitmap.CompressFormat.PNG, 100, stream);
            byte[] byteArray = stream.toByteArray();

            final Session sessionfb = Session.getActiveSession();
            List<String> permissions = sessionfb.getPermissions();
            if (!permissions.contains("publish_actions")) {

                Session.NewPermissionsRequest newPermissionsRequest = new Session.NewPermissionsRequest(
                        MainActivity.this, Arrays.asList("publish_actions"))
                        ;
                sessionfb.requestNewPublishPermissions(newPermissionsRequest);

            }


                Bundle parameters = new Bundle();


              parameters.putByteArray("source", byteArray);


                new Request(sessionfb, "me/photos", parameters, HttpMethod.POST,
                        new Request.Callback() {
                            public void onCompleted(Response response) {
                                progressDialog.dismiss();
                                Log.e("facebook post response",
                                        response.toString());
                            }
                        }).executeAsync();

此代码非常适合上传图片。

我为上传视频做了什么

            Uri uri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.testfile);
            InputStream iStream = getContentResolver().openInputStream(uri);
            byte[] inputData = getBytes(iStream);
            final Session sessionfb = Session.getActiveSession();

            List<String> permissions = sessionfb.getPermissions();
            if (!permissions.contains("publish_actions")) {
                Session.NewPermissionsRequest newPermissionsRequest = new Session.NewPermissionsRequest(
                        MainActivity.this, Arrays.asList("publish_actions"));
                sessionfb.requestNewPublishPermissions(newPermissionsRequest);
            }
                Bundle parameters = new Bundle();
                parameters.putByteArray("source", inputData);
                new Request(sessionfb, "me/videos", parameters, HttpMethod.POST,
                        new Request.Callback() {
                            public void onCompleted(Response response) {
                                progressDialog.dismiss();
                                Log.e("facebook post response",
                                        response.toString());
                            }
                        }).executeAsync();
我错过了什么吗?

总是说“抱歉,您选择的视频文件采用我们不支持的格式。”

0 个答案:

没有答案