提醒:Graph API v2.8将在2019年4月18日弃用。请使用API​​升级工具来了解这可能对您的应用有何影响

时间:2019-04-04 04:35:01

标签: android facebook facebook-graph-api

我收到了有关在Facebook上升级的开发人员提醒

enter image description here enter image description here


我正在使用的代码: 互助朋友

Bundle params = new Bundle();
            params.putString("fields", "context.fields(mutual_friends)");
            new GraphRequest(AccessToken.getCurrentAccessToken(), "/" + userProfileInfoModel.getFacebookId(), params, HttpMethod.GET,
                    new GraphRequest.Callback() {
                        public void onCompleted(GraphResponse response) {
                            facebookFriendsTagId.setText("");
                            fbFriendsApiCallForOtherFriends(response);
                        }
                    }
            ).executeAsync();

我正在使用的

代码: 用于登录

  public void getnSetUserData(AccessToken token, final Session session, final LocationResultCallback locationResultCallback){

        GraphRequest request = GraphRequest.newMeRequest(
                token,
                new GraphRequest.GraphJSONObjectCallback() {
                    @Override
                    public void onCompleted(JSONObject object, GraphResponse response) {
                        Log.v("LoginActivity", response.toString());
                        try {

                            AccessToken token1 = AccessToken.getCurrentAccessToken();
                            String accessToken = token1.getToken().toString();
                            String expiresAt = token1.getExpires().toString();

                            String id = object.getString("id");
                            String gender = object.getString("gender");

                            String userName = object.getString("name");

                            String userEmail = "";
                            if(object.has("email")){
                                userEmail = object.getString("email");
                            }

                            String userLocation = "";
                            String avatarURL = "";
                            String pictureURL = "";
                            try {
                                userLocation = object.getJSONObject("location").getString("name");
                            } catch (Exception e) {
                                userLocation = "";
                            }
                            try {
                                avatarURL = object.getJSONObject("picture").getJSONObject("data").getString("url");
                            } catch (Exception e) {
                                avatarURL = "";
                            }
                            try {
                                pictureURL = "http://graph.facebook.com/" + id + "/picture/?type=large";
                            } catch (Exception e) {
                                pictureURL = "";
                            }

                            UserCreationModel user = new UserCreationModel();
                            user.setId(id);
                            user.setAccessToken(accessToken);
                            user.setExpiresAt(expiresAt);
                            user.setName(userName);
                            user.setLocation(userLocation);
                            user.setEmail(userEmail);
                            user.setAvatarURL(avatarURL);
                            user.setPictureURL(pictureURL);
                            user.setGender(gender);
                            session.setUser(user);

                            starterInit(gender, id, userLocation,locationResultCallback);
                            //locationResultCallback.receivedLocation(id, userLocation);
                        } catch (JSONException e) {
                            EventBus.getDefault().post(new BusFacebookError(e.getMessage()));
                            e.printStackTrace();
                            System.out.println(e.toString());
                        } catch (Exception e){
                            EventBus.getDefault().post(new BusFacebookError(e.getMessage()));
                            System.out.println(e.toString());
                        }

                    }
                });

        Bundle parameters = new Bundle();
        parameters.putString("fields", "id, name, email, gender, location, picture.type(large)");
        //parameters.putString("fields", "id, name, email, location, picture.type(large)");
        request.setParameters(parameters);
        request.executeAsync();
    }

我所做的更改:

我已将gradle更改为:

implementation 'com.facebook.android:facebook-android-sdk:[4,5)'

除了gradle更改外,我还需要哪些更改? ...有吗?

0 个答案:

没有答案