0

我已经尝试了很多代码来在 facebook 墙上发送图像,但它不起作用。我正在使用此代码

Bitmap bitmap =  BitmapFactory.decodeResource(shareDialogContext.getResources(),R.drawable.splash);

byte[] byetArray = convertBitmapToByteArray(shareDialogContext,bitmap);
params.putByteArray("picture",byetArray);
objFacebook.request(profileID + "me/photos", params, "POST");
public byte[] convertBitmapToByteArray(Context context, Bitmap bitmap) {
 ByteArrayOutputStream buffer = new ByteArrayOutputStream(bitmap.getWidth() * 
     bitmap.getHeight());
     bitmap.compress(CompressFormat.PNG, 100, buffer);
     return buffer.toByteArray();                 

}

请提出任何有用的代码。

4

2 回答 2

1

hackbook示例不正是您想要的吗?

                Bundle params = new Bundle();
                try {
                    params.putByteArray("photo",
                            Utility.scaleImage(getApplicationContext(), photoUri));
                } catch (IOException e) {
                    e.printStackTrace();
                }
                params.putString("caption", "FbAPIs Sample App photo upload");
                Utility.mAsyncRunner.request("me/photos", params, "POST",
                        new PhotoUploadListener(), null);
于 2013-08-07T08:53:36.917 回答
0

这可能会帮助您:

 Bundle params = new Bundle();
 try 
 {
     params.putByteArray("photo",Utility.scaleImage(getApplicationContext(), photoUri));
 }
 catch (IOException e) 
 {
     e.printStackTrace();
 }
 params.putString("caption", "Through My Android Application");
 Utility.mAsyncRunner.request("me/photos", params, "POST",new PhotoUploadListener(), null);

可能重复:Android - 使用 Facebook Android SDK 将照片上传到 Facebook

于 2013-08-07T12:00:34.430 回答