如何不像一个用户在Facebook已经喜欢在android系统后不像、喜欢、用户、系统

2023-09-06 17:13:56 作者:永不脱饭!!

我已经写使用Facebook的Andr​​oid应用程序 restfb 。

有关不像一个帖子,Facebook的图形API说要发送一个HTTP上删除对的https://graph.facebook .COM /帖子ID /喜欢与访问令牌

样品code是

 字符串postURL = FacebookAppConstants.GRAPH_API_ACCESS +/+ +帖子ID            /likes&access_token=\"+FacebookAppConstants.accessToken;    Log.out(logFlag,logTag,########删除URL =+ postURL);    HttpDelete dislikePost =新HttpDelete(postURL);    Log.out(logFlag,logTag,####的方法:+ dislikePost.getMethod());    尝试{        HTT presponse响应= httpClient.execute(dislikePost);        Log.out(logFlag,logTag,response.getStatusLine()的toString());    }赶上(ClientProtocolException E){        // TODO自动生成catch块        e.printStackTrace();    }赶上(IOException异常五){        // TODO自动生成catch块        e.printStackTrace();    } 

在执行我从服务器获取错误请求400。

  HTTP / 1.1 400错误的请求    < HTML>< HEAD>D / SMF(2546):其中; TITLE> 400错误的请求和LT; / TITLE>D / SMF(2546):其中; / HEAD>&下; BODY>D / SMF(2546):其中,H1>方法未实现< / H1>D / SMF(2546):在请求和LT无效的方法; P>D / SMF(2546):其中; / BODY>< / HTML> 
Android网络增强 内置购物 博客客户端

解决方案是什么

任何帮助

感谢。

解决方案

 字符串postURL = FacebookAppConstants.GRAPH_API_ACCESS +/+ +帖子ID            /likes&access_token=\"+FacebookAppConstants.accessToken;    Log.out(logFlag,logTag,########删除URL =+ postURL);    HTTPGET dislikePost =新HTTPGET(postURL +&放大器;方法= DELETE);    尝试{        HTT presponse响应= httpClient.execute(dislikePost);        HttpEntity实体= response.getEntity();        绳体= EntityUtils.toString(实体);        Log.out(logFlag,logTag,身体:+体);    }赶上(ClientProtocolException E){        // TODO自动生成catch块        e.printStackTrace();    }赶上(IOException异常五){        // TODO自动生成catch块        e.printStackTrace();    } 

I have written facebook android application using restfb .

For unlike a post , Facebook Graph Api says to send an Http delete to https://graph.facebook.com/postid/likes with the access token

The sample code is

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

    Log.out(logFlag, logTag, "########Delete URL = "+postURL);
    HttpDelete dislikePost = new HttpDelete(postURL);
    Log.out(logFlag,logTag,"####Method : "+dislikePost.getMethod());


    try {
        HttpResponse response = httpClient.execute(dislikePost);

        Log.out(logFlag, logTag,response.getStatusLine().toString());


    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

While executing i am getting BAD Request 400 from the server.

HTTP/1.1 400 Bad Request

    <HTML><HEAD>
D/SMF     ( 2546): <TITLE>400 Bad Request</TITLE>
D/SMF     ( 2546): </HEAD><BODY>
D/SMF     ( 2546): <H1>Method Not Implemented</H1>
D/SMF     ( 2546): Invalid method in request<P>
D/SMF     ( 2546): </BODY></HTML>

What is the solution

Any help

Thanks.

解决方案

    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();
    }