无法从facebook sdk获取朋友的电子邮件ID

时间:2015-09-02 14:08:13

标签: android facebook facebook-graph-api facebook-android-sdk android-facebook

我正在使用facebook sdk 4.4.0。

现在,当我获取当时正在使用我的应用的朋友列表时,我需要检索他们的email。但我没有得到它。

   GraphRequestBatch batch = new GraphRequestBatch(
                    GraphRequest.newMyFriendsRequest(token,
                            new GraphRequest.GraphJSONArrayCallback() {
                                @Override
                                public void onCompleted(JSONArray jsonArray,
                                                        GraphResponse response) {
                                    System.out.println("jsonArray: "
                                            + jsonArray);
                                    System.out.println("GraphResponse: "
                                            + response);
                                    try {

                                        mArrayUserFriendsList = new ArrayList<UserFriendsList>();

                                        for (int i = 0; i < jsonArray.length(); i++) {

                                            mFriendsList = new FriendsList();

                                            JSONObject c = jsonArray
                                                    .getJSONObject(i);

                                            mFriendsList.setname(c
                                                    .getString("email"));

                                            mArrayFriendsList.add(mFriendsList);

                                            mUFriendsListAdapter = new UFriendsListAdapter(
                                                    getActivity(), mArrayFriendsList);
                                            user_friends
                                                    .setAdapter(mFriendsListAdapter);
                                            mFriendsListAdapter
                                                    .notifyDataSetChanged();

                                        }

                                    } catch (JSONException e) {
                                        e.printStackTrace();
                                    }

                                }
                            }), GraphRequest.newMeRequest(token,
                    new GraphRequest.GraphJSONObjectCallback() {

                        @Override
                        public void onCompleted(JSONObject object,
                                                GraphResponse response) {
                            System.out.println("meJSONObject: "
                                    + object);
                            System.out.println("meGraphResponse: "
                                    + response);

                        }
                    }));
            batch.addCallback(new GraphRequestBatch.Callback() {
                @Override
                public void onBatchCompleted(GraphRequestBatch graphRequests) {
                    // Log.i(TAG, "onCompleted: graphRequests "+ graphRequests);
                }
            });
            batch.executeAsync();

            Bundle parameters = new Bundle();
            parameters.putString("fields",
                    "id,first_name,email,gender,birthday");
         //  request.setParameters(parameters);
         //  request.executeAndWait();

当我写name而不是email时,它会给我一个朋友列表的名称。

如何获取电子邮件信息?

0 个答案:

没有答案