我正在尝试设置一个方法将图像发布到用户的Facebook墙上,但我设置的内容并不起作用。
这里是我的代码,有人知道我做错了什么吗?我能够获得用户名和picturee.t.c但无法发布。我是否需要添加任何其他权限?我还没有设置任何内容。
try {
outputphoto = MediaStore.Images.Media.getBitmap(
this.getContentResolver(), mImageUri);
int WIDTH = outputphoto.getWidth();
int HEIGHT = outputphoto.getHeight();
Log.d("WIDTH", String.valueOf(WIDTH));
Log.d("HEIGHT", String.valueOf(HEIGHT));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Request.Callback uploadPhotoRequestCallback = new Request.Callback() {
@Override
public void onCompleted(Response response) {
if (response.getError() != null) {
// post error
} else {
String idRploadResponse = (String) response
.getGraphObject().getProperty("id");
if (idRploadResponse != null) {
String fbPhotoAddress = "https://www.facebook.com/photo.php?fbid="
+ idRploadResponse;
} else {
// error
}
}
}
};
Request request = Request.newUploadPhotoRequest(
Session.getActiveSession(), outputphoto,
uploadPhotoRequestCallback);
Bundle parameters = request.getParameters(); // <-- THIS IS
// IMPORTANT
parameters.putString("message", "My message");
// add more params here
request.setParameters(parameters);
request.executeAsync();
答案 0 :(得分:0)
您需要publish_actions权限才能上传照片。