Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Share link and text with Android Facebook SDK 3.0

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.

like image 203
johnw182 Avatar asked Jun 09 '13 02:06

johnw182


People also ask

How did you integrate the Facebook SDK in Android app?

To use the Facebook SDK in an Android Studio project, add the SDK as a build dependency and import the SDK. Go to Android Studio | New Project | Minimum SDK. Select API 15: Android 4.0. 3 (IceCreamSandwich) or higher and create your new project.

What SDK does Facebook use?

Facebook Android SDK enables mobile developers build Facebook apps for Android. It includes features like tracking analytics, data trends, insights on the traffic on your app. User behaviour on how people interact with your app. It also helps track ads engagements, which ads are working which aren't.

What is Facebook SDK work with flutter?

Facebook Sdk For Flutter facebook_sdk_flutter allows you to fetch deep links , deferred deep links and log facebook app events . This was created using the latest facebook SDK to include support for iOS 14. The plugin currently supports app events and deeps links for iOS and Android.


1 Answers

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();
like image 139
johnw182 Avatar answered Oct 22 '22 10:10

johnw182