我一直在按照教程在这里创建一个开放的图表故事。一切都很好,但我希望上传的图像很大,即“用户生成”。
我的问题在于实际实施。这是从 SD 卡获取图像的代码:
// If uploading an image, set up the first batch request
// to do this.
// Set up image upload request parameters
Bundle imageParams = new Bundle();
Bitmap image = BitmapFactory.decodeFile(getActivity().getIntent().getStringExtra("image_for_facebook"));
// Set up the image upload request callback
Request.Callback imageCallback = new Request.Callback() {
@Override
public void onCompleted(Response response) {
// Log any response error
FacebookRequestError error = response.getError();
if (error != null) {
dismissProgressDialog();
Log.i(TAG, error.getErrorMessage());
}
}
};
// Create the request for the image upload
Request imageRequest = Request.newUploadStagingResourceWithImageRequest(Session.getActiveSession(),
image, imageCallback);
// Set the batch name so you can refer to the result
// in the follow-on object creation request
imageRequest.setBatchEntryName("imageUpload");
// Add the request to the batch
requestBatch.add(imageRequest);
这是随后为图形对象提供其属性的位:
// Set up the OpenGraphObject representing the book.
OpenGraphObject book = OpenGraphObject.Factory.createForPost("books.book");
// Set up the book image; if we uploaded the image, it is the "uri" result from the previous
// batch request, otherwise it is just a URL.
String imageUrl = "{result=imageUpload:$.uri}";
book.setImageUrls(Arrays.asList(imageUrl));
book.setTitle("A Game of Thrones");
book.setUrl("https://facemash.biz/books/a_game_of_thrones/");
book.setDescription("In the frozen wastes to the north of Winterfell, sinister and supernatural forces are mustering.");
// books.book-specific properties go under "data"
book.getData().setProperty("isbn", "0-553-57340-3");
我需要做什么才能将此处显示的图像的“user_generated”参数设置为 true?(当然假设我认为这就是获得大图像而不是缩略图所要做的一切是正确的)。
谢谢!