尝试从facebook api获取好友数-android [英] attempting to get the number of friends from facebook api - android

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

问题描述

我正在尝试调用android权限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/graph-api/reference/user/friends/

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

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