我使用restfb编写了facebook android应用程序。
对于不同的帖子,Facebook Graph Api表示将Http删除发送到https://graph.facebook.com/postid/likes 使用访问令牌
示例代码是
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();
}
执行时我从服务器获取BAD请求400.
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>
解决方案是什么
任何帮助
感谢。
答案 0 :(得分:2)
要检查的三件事:
publish_stream
extended permission?&method=delete
- Facebook API会将其视为'DELETE',即使它在GET请求中到达< / LI>
醇>
400错误的正文中应该有更好的错误消息 - 如果你提供的话我们可能会帮助更多
答案 1 :(得分:1)
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();
}