Android: 无法将图片上传到 facebook 相册

Android: unable to upload image to facebook album

我正在编写将图片上传到 facebook 相册的代码 "Profile Images",从图库中选择图片后,它会转换为字节数组 imageBytes 并发送到 AsyncTask。我使用以下代码上传图片。 facebookProfileImagesAlbumId 有相册的 ID "Profile Images"

 Bundle params_ = new Bundle();
 String encodedImage = Base64.encodeToString(imageBytes, Base64.DEFAULT);

 params_.putString("source", encodedImage);
 /* make the API call */
 new GraphRequest(
        AccessToken.getCurrentAccessToken(),
        "/"+facebookProfileImagesAlbumId+"/photos",
        params_,
        HttpMethod.POST,
        new GraphRequest.Callback() {
              public void onCompleted(GraphResponse response) {
                   Log.i("Login", response.toString());
              }
        }).executeAndWait();

但它不起作用,Log.i("Login", response.toString()); 给出以下消息

{Response: responseCode: 200, graphObject: null, error: {HttpStatus: -1, errorCode: -1, errorType: null, errorMessage: could not construct request body}}

我正在使用 Facebook Graph API 2.4

我已使用以下代码将图像 Post 上传到 Facebook 墙或特定相册。

public void PostImage(Bitmap bitmap) {
        AccessToken token = AccessToken.getCurrentAccessToken();
        if (token != null) {
            Bundle parameters = new Bundle(2);
            parameters.putParcelable("source", bitmap);
            parameters.putString("message", "description");
            new GraphRequest(token, "/"+facebookProfileImagesAlbumId+"/photos", parameters, HttpMethod.POST, new GraphRequest.Callback() {

                public void onCompleted(GraphResponse response) {
                    Log.e("Image Post", "Res =" + response.toString());
                }
            }).executeAsync();
        }
    }

希望对您有所帮助!