【问题标题】:Facebook API 2.1 how to query and get the data outputFacebook API 2.1 如何查询和获取数据输出
【发布时间】:2014-10-19 13:15:22
【问题描述】:

我正在尝试通过 Facebook API 2.1 获取我的 ID

https://graph.facebook.com/v2.1/me&fields=id&access_token="+accesstoken

我收到错误 200 但没有数据。

有没有人举例说明如何从查询 2.1 中获取和提取我的 id、姓名或任何数据?

【问题讨论】:

    标签: java android facebook-graph-api-v2.0


    【解决方案1】:

    那是因为我&field=id 必须是我吗?field=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。见Using the Graph API

    使用 facebook sdk 的示例图 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();
    

    【讨论】:

    • 错误 400 表示您的令牌已过期。更新它然后简单地做json解析人员
    • 错误在这里 try { jsonObject = new JSONObject( response.getGraphObject() .getInnerJSONObject() .toString());
    • 我在 v1.0 中做了 json 解析,但在 v2.0 中它不适合我如何编写 json 解析?
    • v2.1 见文档
    • /我你已经有了。您不需要专门设置 field = id,name
    猜你喜欢
    • 2020-01-30
    • 1970-01-01
    • 2020-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-14
    • 1970-01-01
    相关资源
    最近更新 更多