Android How to like a post with facebook 3.0 sdk

2019-03-28 11:19发布

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

2条回答
祖国的老花朵
2楼-- · 2019-03-28 11:36

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);
查看更多
不美不萌又怎样
3楼-- · 2019-03-28 11:52

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.

查看更多
登录 后发表回答