Android How to like a post with facebook 3.0 sdk
Asked Answered
E

2

6

I want to implement "Like" option in my Android app, but I don't know which Request to use.

I have a valid facebook Session opened and the ID post I want to like.

How can I implement this function?

Thanks

Edvard answered 3/1, 2013 at 21:55 Comment(0)
E
13

I found a solution.

To like post I've implemented a simple POST request using likes connection of facebook post id.

This is the code:

Request likeRequest = new Request(Session.getActiveSession(), fBPostId + "/likes", null, HttpMethod.POST, new Request.Callback() {

         @Override
         public void onCompleted(Response response) {
                Log.i(TAG, response.toString());
         }
});
Request.executeBatchAndWait(likeRequest);
Edvard answered 4/1, 2013 at 13:34 Comment(4)
Please accept your own solution instead of the current one accepted.Kozak
Additionally, merely change the HttpMethod of the same call from HttpMethod.POST to HttpMethod.DELETE to "unlike" something.Misbegotten
What "id" returned by JSON should i use? the second part of the "id" or the "object_id" ?Reader
@Giulio Bider ... Where i have to include this code..? please explain meGrouse
S
0

A cursory search (1, 2, 3) seems to indicate that it's not possible to directly "Like" things as a user via the Graph API, for security/spam reasons. One commonly-suggested alternative has traditionally been to show a Facebook-controlled "Like" button in a WebView and include that in your application instead.

However, more recently, the Facebook developer guide has provided one possible solution for how you can implement "like"-style functionality in your app when it comes to publishing stories on the user's behalf, though it's not precisely the same thing as what you seem to be asking for.

Schappe answered 3/1, 2013 at 22:12 Comment(3)
No, it's not what I need. So I can't post a comment to a post too??Edvard
This is incorrect, for all googling, The answer by @Cromir is correct.Crenellate
@Crenellate Glad to hear it. Unfortunately, I can't delete my answer while it's accepted. Cromir, would you mind accepting your own answer (if it's possible)?Schappe

© 2022 - 2024 — McMap. All rights reserved.