有人可以帮我吗?我想在 Facebook 上发帖并从 sdcard 中放一张图片。如果我使用 URL - 一切正常。但是我应该怎么做才能从 sdcard 上传图片呢?也许我需要先像照片一样在 Facebook 上下载它,然后再获取它的网址?但是我怎样才能获得最近上传的照片的网址呢?
Bundle postParams = new Bundle();
postParams.putString("name", title);
postParams
.putString("caption", caption);
postParams.putString("description", description);
postParams
.putString("link",
"https://");
postParams
.putString(
"picture",
"https://");
Request.Callback callback = new Request.Callback() {
public void onCompleted(Response response) {
if (response.getError() == null) {
JSONObject graphResponse = response.getGraphObject()
.getInnerJSONObject();
String postId = null;
try {
postId = graphResponse.getString("id");
} catch (JSONException e) {
Log.i("Facebook Error",
"JSON error " + e.getMessage());
}
FacebookRequestError error = response.getError();
if (error != null) {
} else {
}
}
}
};
Request request = new Request(session, "me/feed", postParams,
HttpMethod.POST, callback);
RequestAsyncTask task = new RequestAsyncTask(request);
task.execute();