Android – Share link and text with Android Facebook SDK 3.0

androidfacebookpostsdkshare

Im trying to upgrade to the Facebook SDK 3.0 and have finally gotten everything to work with Request.newStatusUpdateRequest(). However my app shares/posts text along with a link. I have tried/looked into the following:

Request.newStatusUpdateRequest()

This does not seem to have any options for a Bundle or any other way to include a link and icon.

Request.newRestRequest()

Skipped this because I saw REST was being depreciated.

new WebDialog.FeedDialogBuilder(_activity, session, params).build().show();

This actually works pretty well but the resulting post does not seem to be linked to my Facebook App and I am not sure how this will effect my Facebook insights.

Request.newPostRequest()

From what I have read, this method seems to be the proper way. However, i cannot figure out where to get the GraphObject to pass in as one of the parameters.

What is the PROPPER way to post/share text, link and image to the user's wall? It seems to be Request.newPostRequest() so I will include the code I have for that.

Request request = Request.newPostRequest(session, "me/feed", ??graph_object??, new Request.Callback() {
    @Override
    public void onCompleted(Response response) {
        showPublishResult("message", response.getGraphObject(), response.getError());
    }
});
request.setParameters(params);
Request.executeBatchAsync(request);

But what really is a GraphObject? Where do i get the graph_object? The more I read from FB on GraphObject/OpenGraph/Graph API the more I get confused.

If I am heading down the wrong direction entirely, please tell me. If Request.newPostRequest is the propper way of doing this, please give me more information on the GraphObject param.

Best Solution

Finally managed to get everything I needed with the Facebook SDK 3.0 using the following:

Bundle params = new Bundle();
params.putString("caption", "caption");
params.putString("message", "message");
params.putString("link", "link_url");
params.putString("picture", "picture_url");

Request request = new Request(Session.getActiveSession(), "me/feed", params, HttpMethod.POST);
request.setCallback(new Request.Callback() {
    @Override
    public void onCompleted(Response response) {
        if (response.getError() == null) {
            // Tell the user success!
        }
    }
});
request.executeAsync();