我将最新的 facebook SDK 4.0.1
包含到 Android Studio 项目中。我想执行 Graph API reference 中列出的基本图形 API 调用
/* make the API call */
new Request(
session,
"/me",
null,
HttpMethod.GET,
new Request.Callback() {
public void onCompleted(Response response) {
/* handle the result */
}
}
).executeAsync();
但我无法导入 Request
类,出现错误 Cannot resolve symbol
Request``。
如何解决这个问题?我需要导入其他库才能使用 Graph API 吗?
谢谢。
最佳答案
除了 Request
更改为 GraphRequest
,Response
更改为 GraphResponse
并且现在不再传递 session
,在构造函数中传递AccessToken.getCurrentAccessToken或accessToken
。所以你的查询将是这样的:
GraphRequestAsyncTask graphRequest = new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/{user-id}/",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
}
}
).executeAsync();
关于java - "Cannot resolve symbol ` Facebook Graph API 请求 `"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29809370/