试图从 facebook api - android 获取朋友的数量 [英] attempting to get the number of friends from facebook api - android

查看:22
本文介绍了试图从 facebook api - android 获取朋友的数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试调用 facebook 权限 api 所需的 android 应用程序中来自 facebook 身份验证 api 的朋友数量.下面是我正在使用的片段

I am attempting to the number of friends from facebook authentication api in an android application needed to call facebook permission api. Below is a snippet I am using

fbLoginButton.setReadPermissions(Arrays.asList("public_profile, email, user_birthday, user_friends"));

应用程序在此行失败并出现 json 异常

the app fails with a json exception at this line

PUBLICPROFILE = object.getString("public_profile"); //error here

已编辑 - 这是我尝试的片段:

Name = object.getString("name");
                                    Email = object.getString("email");
                                    DOB = object.getString("birthday");
                                    DOB = object.getString("birthday");
                                    PUBLICPROFILE = object.getString("/me/friends");
                                    Log.v("Email = ", " " + Email);
                                    Log.v("PUBLIC PROFILE = ", " " + PUBLICPROFILE);

请问有谁知道我如何在 android 登录身份验证上从 facebook 获得好友数量

Please does anyone know how I can the number of friends from facebook on android login authentication

推荐答案

根据 facebook developer api /{user-id}/friends

1.已安装应用的用户朋友

1.the User's friends who have installed the app

2.用户的好友总数(包括未安装应用进行查询的用户)

2.the User's total number of friends (including those who have not installed the app making the query)

获得 facebook 令牌后,您可以使用此实现

After getting facebook token you can use this implementation

     GraphRequest request = GraphRequest.newGraphPathRequest(
      accessToken,
      "/{user-id}/friends",
      new GraphRequest.Callback() {
        @Override
        public void onCompleted(GraphResponse response) {
          // Insert your code here
        }
    });

    request.executeAsync();

https://developers.facebook.com/docs/图 api/reference/user/friends/

这篇关于试图从 facebook api - android 获取朋友的数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆