How to get Facebook photo, full name, gender using Facebook SDK android

前端 未结 6 1030
闹比i
闹比i 2020-12-13 05:05

I am working on an Android application in which any Android user who is logging to Facebook using our Application, I need to extract his photo, his gender, his full name fro

6条回答
  •  天涯浪人
    2020-12-13 05:29

    with new API

    private void importFbProfilePhoto() {
    
        if (AccessToken.getCurrentAccessToken() != null) {
    
            GraphRequest request = GraphRequest.newMeRequest(
                    AccessToken.getCurrentAccessToken(), new GraphRequest.GraphJSONObjectCallback() {
                        @Override
                        public void onCompleted(JSONObject me, GraphResponse response) {
    
                            if (AccessToken.getCurrentAccessToken() != null) {
    
                                if (me != null) {
    
                                    String profileImageUrl = ImageRequest.getProfilePictureUri(me.optString("id"), 500, 500).toString();
                                    Log.i(LOG_TAG, profileImageUrl);
    
                                }
                            }
                        }
                    });
            GraphRequest.executeBatchAsync(request);
        }
    }
    

提交回复
热议问题