How to Upload Photos with text in same request? [closed]

点点圈 提交于 2020-01-01 18:21:01

问题


I m using Eclipse / Android - Facebook SDK and i need to upload Photos with text at same request. There is a sample in SDK but it post Photos without any text to explain the picture.

Any body know how to do that ?


回答1:


I'm programming android and facebook sdk in a week and, as nobody answer my question and includind vote against my post i solve the SDK limitation by my self and add a method to implement ulpload of photos with captions. bellow the solution:

Insert this code into com.facebook -> request.java

public static Request newMyUploadPhotoRequest(Session session,  Bitmap image, String caption,String description,
        Callback callback)  {
    Bundle parameters = new Bundle(3);
    parameters.putParcelable(PICTURE_PARAM, image);
    parameters.putString("caption",caption);
    parameters.putString("description",description );

    return new Request(session, MY_PHOTOS, parameters, HttpMethod.POST, callback);


}

Call method from your activity

        Bitmap image = BitmapFactory.decodeFile(picturePath);
        Request request = Request.newMyUploadPhotoRequest(Session.getActiveSession(), image,"Teste Caption", "teste description", new Request.Callback() {
            @Override
            public void onCompleted(Response response) {
                showPublishResult(getString(R.string.photo_post), response.getGraphObject(), response.getError());
            }
        });
        Request.executeBatchAsync(request);


来源:https://stackoverflow.com/questions/14025095/how-to-upload-photos-with-text-in-same-request

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!