我正在尝试通过Facebook API 2.1 获取我的id
https://graph.facebook.com/v2.1/me&fields=id&access_token="+accesstoken
我得到错误200,但没有数据。
有人举过如何从查询2.1中获取和提取我的id、姓名或任何数据的例子吗?
那是因为我&field=id一定是我?字段=id
https://graph.facebook.com/v2.1/me?fields=id&access_token=accesstoken
对于所有公共用户信息
https://graph.facebook.com/v2.1/me?access_token=accesstoken
我建议你使用Facebook SDK。请参阅使用图形API
使用facebooksdk:的示例图api-me请求
new Request(
Session.getActiveSession(),
"/me",
null,
HttpMethod.GET,
new Request.Callback() {
@Override
public void onCompleted(Response response) {
GraphObject graphObject = response.getGraphObject();
if (graphObject != null) {
if (graphObject.getProperty("id") != null) {
String fbId = graphObject.getProperty("id").toString();
String userName = graphObject.getProperty("name").toString();
}
}
}
}
).executeAsync();