Question

J'ai écrit facebook Application Android en utilisant restfb .

Pour la différence d'un poste, Facebook Graph Api dit d'envoyer un Http supprimer https: //graph.facebook .com / postID / aime avec le jeton d'accès

Le code échantillon est

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

Lors de l'exécution je reçois BAD demande 400 du serveur.

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>

Quelle est la solution

Toute aide

Merci.

Était-ce utile?

La solution 2

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

Autres conseils

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top