How to unlike a post that a user has liked in facebook in android

别说谁变了你拦得住时间么 提交于 2019-12-08 05:38:23

Three things to check:

  1. Do you have the publish_stream extended permission for that user?
  2. Does the user actually like the post already?
  3. Is there a proxy server in the middle which could be causing the HTTP DELETE request to be dropped? try 'faking' a DELETE request by making a GET request but adding a parameter, &method=delete to the request you're making - the Facebook API will treat this as a 'DELETE' even if it arrives in a GET request

There should be a better error message coming back in the body of the 400 error - if you provide that we can probably help more

    String postURL = FacebookAppConstants.GRAPH_API_ACCESS+"/"+postID+
            "/likes&access_token="+FacebookAppConstants.accessToken;

    Log.out(logFlag, logTag, "########Delete URL = "+postURL);

    HttpGet dislikePost = new HttpGet(postURL+"&method=DELETE");


    try {
        HttpResponse response = httpClient.execute(dislikePost);
        HttpEntity entity = response.getEntity();
        String body = EntityUtils.toString(entity);
        Log.out(logFlag, logTag, "Body : "+body);           

    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!