我想提取喜欢特定页面的人的详细信息。我正在尝试但现在我正在尝试根据我指定的关键字从页面中提取评论/帖子。我工作,但不好用,因为只有一些页面显示输出,并显示我指定的所有其他关键字的一些例外。这是我的示例代码。如何获得喜欢特定页面的用户的信息?
Facebook facebook = new FacebookFactory().getInstance();
ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
facebook.setOAuthAppId("", "");
configurationBuilder
.setOAuthPermissions("id, name, first_name, last_name,likes");
String accessTokenString = "*****";
AccessToken at = new AccessToken(accessTokenString);
configurationBuilder.setOAuthAppId("1466708753544336");
configurationBuilder.setOAuthAppSecret("*****");
facebook.setOAuthAccessToken(at);
@SuppressWarnings("resource")
Scanner sc=new Scanner(System.in);
String s=sc.nextLine();
ResponseList<Post> posts=facebook.getPosts(s,new Reading().limit(100));
StringBuilder str = new StringBuilder();
ResponseList<Post> res =facebook.getPosts(s);
for(Post post :res)
{
//str.append(post.getMessage());
for(int i=0;i<post.getComments().size();i++)
{
str.append(post.getComments().get(i).getMessage());
str.append(post.getComments().get(i).getId());
}
}
System.out.println(str);
}//try
catch(Exception e)
{
e.printStackTrace();
}
当我输入“Ice-Cream”时,它会显示某些关键字的此类异常。我不知道这有什么问题。任何形式的帮助将不胜感激
Ice-Cream
FacebookException{statusCode=400, response=
HttpResponse{statusCode=400, responseAsString='<!DOCTYPE html PUBLIC "-//
W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en" lang="en" id="facebook">
<head>
<title>Facebook | Error</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Cache-Control" content="no-cache" />
<meta name="robots" content="noindex,nofollow" />
<style type="text/css">
html, body {
margin: 0px;
padding: 0px;
text-align: center;
font-family: "Lucida Grande", "Tahoma", "Verdana", "Arial", sans-serif;
color: #333333;
}
a.menu {
margin: auto;
position: relative;
display: block;
width: 964px;
height: 29px;
background: #3B5998 url('https://s-static.ak.fbcdn.net/common/error.png')
top center no-repeat;
}
.core {
text-align: left;
margin: auto;
width: 904px;
padding: 1em 0em;
}
h1 {
font-size: 18px;
}
p {
font-size: 13px;
}
.footer {
border-top: 1px solid #DDDDDD;
color: #777777;
float: left;
width: 904px;
padding: 5px 8px 6px 0;
font-size: 11px;
}
</style>
<script type="text/javascript" charset="utf-8">
function back() {
if (1 < history.length) {
history.back();
return false;
}
return true;
}
</script>
</head>
<body>
<a class="menu" href="http://www.facebook.com/"></a>
<div class="core">
<h1>Sorry, something went wrong.</h1>
<p>We're working on getting this fixed as soon as we can.</p>
<p><a onclick="return back();" href="http://www.facebook.com/">Go Back</a></p>
<div class="footer" id="pagefooter_copyright">
Facebook ©
2013
·
<a href="http://www.facebook.com/help/">Help</a>
</div>
</div>
</body>
</html>
', is=sun.net.www.protocol.http.HttpURLConnection
$HttpInputStream@60e3907d, streamConsumed=true}, errorType='null',
errorMessage='null', errorCode=-1, errorSubcode=-1}
at facebook4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:189)
at facebook4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.java:65)
at facebook4j.internal.http.HttpClientWrapper.get(HttpClientWrapper.java:93)
at facebook4j.FacebookImpl.get(FacebookImpl.java:2431)
at facebook4j.FacebookImpl.getPosts(FacebookImpl.java:691)
at facebook.NewTest.main(NewTest.java:41)