gpt4 book ai didi

android - 用户为来自 Android 的 Open Graph 生成的图像

转载 作者:行者123 更新时间:2023-11-29 00:25:28 24 4
gpt4 key购买 nike

我一直在按照教程创建一个开放图故事 here .一切正常,但我希望上传的图像较大,即“用户生成”。

我的问题是实际执行它。这是从 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”参数 here是真实的? (当然假设我认为这就是获得大图像而不是缩略图所需要做的一切是正确的)。

谢谢!

最佳答案

查看 SelectionFragment.java 中的 Scrumptious 示例的 getImageObject 方法。基本上,您需要创建一个具有“url”和“user_generated”属性的图形对象:

    GraphObject imageObject = GraphObject.Factory.create();
imageObject.setProperty("url", "{result=imageUpload:$.uri}");
imageObject.setProperty("user_generated", "true");
GraphObjectList<GraphObject> images = GraphObject.Factory.createList(GraphObject.class);
images.add(imageObject);
book.setImage(images);

关于android - 用户为来自 Android 的 Open Graph 生成的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19957711/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com