2

From within my Android application, i am trying to implement a simple "Like Button" functionality.

We have already executed Facebook log in from the same app. We have also created an Open Graph Like action & a Link object as well on our App's Dashboard.

This is the code that we are using to publish the like.

public static void likeFacebookPage(Context context,String pageUrl)
{
    Bundle params = new Bundle();
    params.putString("object",pageUrl);
    Request request = new Request(
        Session.getActiveSession(),
        "me/og.likes",
        params,
        HttpMethod.POST
    );
    Response response = request.executeAndWait();
    // handle the response

}

In the pageUrl parameter, we have:

http://www.facebook.com/<object_id>

"object_id" is the Id of the Link Object that we have created in Open Graph.

After executing the above method, the response object received as follows:

{Response:  responseCode: 200, graphObject: null, error: {HttpStatus: -1, errorCode: -1, errorType: null, errorMessage: null}, isFromCache:false}

But the Like count is not getting updated, leading us to believe that this process is not working.

We have also included the permissions "publish_actions" & "user_likes" in our code as well as on the App Dashboard.

Kindly help us with configuring this functionality.

Thanks in advance.

2
  • i do have the same problem .. any solutions ?
    – Zak
    Jun 3, 2013 at 9:21
  • same problem, any update??
    – Jaume
    Jul 1, 2013 at 23:05

1 Answer 1

0

As described here https://developers.facebook.com/docs/reference/api/publishing/ you publish a like to an object like so with the publish_actions and publish_stream permissions:

    Bundle postParams = new Bundle();
    Request request = new Request(Session.getActiveSession(),
            FB_OBJECT_ID+"/likes", postParams, HttpMethod.POST, new Callback() {

                @Override
                public void onCompleted(Response response) {

                }
            });
    RequestAsyncTask task = new RequestAsyncTask(request);
    task.execute();

Where your FB_OBJECT_ID is simply the ID of the object. I.e if you want to like a photo, FB_OBJECT_ID would be the pid. For an album, FB_OBJECT_ID would be the aid.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.