问题
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