2

チュートリアルに従って、オープン グラフ ストーリーを作成しまし。すべてがうまく機能しますが、アップロードされた画像を大きくしたいと思います。つまり、「ユーザー生成」です。

私の問題は、実際にそれを実装することです。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 に設定するにはどうすればよいですか? (もちろん、サムネイルではなく大きな画像を取得するために必要なことはそれだけだと私が考えているのは正しいと仮定します)。

ありがとう!

4

2 に答える 2

2

Scrumptious サンプルの SelectionFragment.java の 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);
于 2013-11-13T18:38:11.143 に答える