我已经尝试了数千种方法,但都没有奏效。每次帖子都不会出现。我之前设法发布过文字,但图像永远无法正常工作......
try {
String response = facebook.request("me");
Bundle parameters = new Bundle();
String DIRECTORY_PATH = Environment.getExternalStorageDirectory().getAbsolutePath() + "/img/img.jpg";
Bitmap bitmap = BitmapFactory.decodeFile(DIRECTORY_PATH);
byte[] data = null;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
data = baos.toByteArray();
parameters.putString("message", "picture caption");
parameters.putByteArray("source", data); //I try "picture" too
String pageid = "152390368241461";
response = facebook.request(pageid + "/photos", parameters,
"POST");
Log.d("Tests", "got response: " + response);
if (response == null || response.equals("") ||
response.equals("false")) {
Log.v("Error", "Blank response");
}
showToast(getResources().getString(R.string.sucessharefc));
} catch(Exception e) {
e.printStackTrace();
}