简体   繁体   English

如何从Android相册中获取Facebook登录用户图像?

[英]How to get facebook login user images from albums in android?

How to i get the logged user images from album in GridView?. 如何从GridView的相册中获取记录的用户图像? Where i used developers.facebook code also like "me/albums" but its not working.. 我在哪里使用developers.facebook代码,也喜欢“我/相册”,但无法正常工作。

loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            Profile profile = Profile.getCurrentProfile();
            info.setText(message(profile));
            String userId = loginResult.getAccessToken().getUserId();
            final String accessToken = loginResult.getAccessToken().getToken();
            prefUtil.saveAccessToken(accessToken);
            final String profileImgUrl = "https://graph.facebook.com/" + userId + "/picture?type=large";

            Log.d("token", accessToken);
            Picasso.with(MainActivity.this).load(profileImgUrl).into(profileImgView);
            AccessToken.getCurrentAccessToken().getPermissions();

            GraphRequest request = GraphRequest.newMeRequest(AccessToken.getCurrentAccessToken(),new GraphRequest.GraphJSONObjectCallback() {
                @Override
                public void onCompleted(JSONObject object,GraphResponse response) {
                    Log.v("MainActivity", response.toString());
                    try {
                        JSONObject photosobject = object.getJSONObject("photos");
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    });
            Bundle parameters = new Bundle();
            parameters.putString("fields", "id,name,picture,photos{link}");
            request.setParameters(parameters);
            request.executeAsync();

        }
        @Override
        public void onCancel() {
            info.setText("Login attempt cancelled.");
        }
        @Override
        public void onError(FacebookException e) {
            e.printStackTrace();
            info.setText("Login attempt failed.");
        }
    });

You can try this API. 您可以尝试使用此API。 It has simple approach to achieve all that you need. 它具有实现所需所有内容的简单方法。

https://github.com/sromku/android-simple-facebook https://github.com/sromku/android-simple-facebook

It is nice and simple API instead of complex Facebook SDK 它是很好的简单API,而不是复杂的Facebook SDK

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM