Facebook4j API:搜索 [英] Facebook4j API : Search
问题描述
我使用Facebook4j获取与关键字状态
I'm using Facebook4j to get status with a keyword
facebook4j.conf.ConfigurationBuilder fac = new facebook4j.conf.ConfigurationBuilder();
fac.setDebugEnabled(true)
.setOAuthAppId("******")
.setOAuthAppSecret("********")
.setOAuthPermissions("email,publish_stream,...");
FacebookFactory ff = new FacebookFactory(fac.build());
facebook = ff.getInstance();
new Thread(new Runnable() {
@Override
public void run() {
try {
search();
}
catch (Exception e) {
// TODO: handle exception
System.out.println(e +" ERROOOOOOR");
}}}).start();
}
//search
public void search() throws Exception {
ResponseList<JSONObject> results = facebook.search("%23morocco");
System.out.println(results);
for (JSONObject result : results) {
System.out.println(result);
}
results = facebook.search("orange", new Reading().until("yesterday"));
System.out.println(results);
for (JSONObject result : results) {
System.out.println(result);
}
}
我取代的 * 的与Facebook的API密钥
我有一个例外probleme,错误的是:
java.lang.IllegalStateException:没有可用的令牌。 ERROOOOOOR
I replaced * with facebook api key I have a exception probleme , the error is : java.lang.IllegalStateException: No Token available. ERROOOOOOR
推荐答案
您忘了设定访问令牌fac.setOAuthAccessToken(*****)
。从文档(重点煤矿):
You forgot to set the access token with fac.setOAuthAccessToken("*****")
. From the docs (emphasis mine):
所有的图形API搜索查询需要访问令牌一>通过与的access_token =&LT;令牌GT;
参数。访问令牌,你需要的类型取决于搜索你执行的类型。
All Graph API search queries require an access token passed in with the
access_token=<token>
parameter. The type of access token you need depends on the type of search you're executing.
- 横渡
页
和地方
对象搜索需要的应用程序访问令牌。 - 所有其它端点需要用户访问令牌
- Searches across
page
andplace
objects requires an app access token. - All other endpoints require a user access token.
您可以生成一个自己这里,但请记住,这些访问令牌具有过期时间。
You can generate one for yourself here, but remember that these access tokens have an expiration time.
这篇关于Facebook4j API:搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!