摘要:尝试在 Facebook 上发布图片和描述。如果图像 URL 为空,我使用本地可绘制默认图像上传到照片。
要上传本地图像,我使用以下代码:
我的代码:
Request.Callback uploadPhotoRequestCallback = new Request.Callback() {
@Override
public void onCompleted(Response response) {
if (response.getError() != null) {
//post error
} else{
String uploadResponse = (String) response.getGraphObject().getProperty("id");
if (uploadResponse is valid) {
parameters.putString("message", description);
} else {
//error
}
}
}
};
Request request = Request.newUploadPhotoRequest(Session.getActiveSession(), BitmapFactory.decodeResource(_context.getResources(), R.drawable.default_image), uploadPhotoRequestCallback);
request.setParameters(parameters);
Request.executeBatchAsync(request);
这通过以下方式执行:
{HttpStatus: 400, errorCode: 324, errorType: OAuthException, errorMessage: (#324) Requires upload file}
注意事项:
1.图片上传成功没有
request.setParameters(parameters);
2.试过parameters.putString("name", description);
而不是
parameters.putString("message", description);
为什么添加参数会导致 OAuthException?