5

I am trying to get education detail and work description of user from facebook. I login successfully and get Access token. But I am unable to get details I want

Code I am using for it :-

    public void getUserExpandEducation() {

    new GraphRequest(
            AccessToken.getCurrentAccessToken(),
        "/{education-experience-id}",  //"/{user_education_history}",//  
            null,
            HttpMethod.GET,
            new GraphRequest.Callback() {
                public void onCompleted(GraphResponse response) {
                    Log.d("fb response",response.toString());
                }
            }
    ).executeAsync();
}

can anyone please reply

I am getting error (#803) Some of the aliases you requested do not exist: {education-experience-id}

dbc
  • 104,963
  • 20
  • 228
  • 340
Akanksha Rathore
  • 3,603
  • 3
  • 31
  • 47
  • how about replacing the string with an actual id? – andyrandy May 27 '16 at 09:22
  • It's a permission URL which we need to pass. How can I get actual id of user education – Akanksha Rathore May 27 '16 at 09:34
  • /{education-experience-id} - that´s just a placeholder from the docs. of course you need to replace it. not sure what you mean with permission url, login is a completely different topic. you need to authorize BEFORE using that endpoint. is the issue how to get that id? – andyrandy May 27 '16 at 09:45

2 Answers2

4

Finally I got full work and education detail by this code:

GraphRequest request = GraphRequest.newMeRequest(
            accessToken,
            new GraphRequest.GraphJSONObjectCallback() {
                @Override
                public void onCompleted(
                        JSONObject object,
                        GraphResponse response) {

                    FirstNameSocial = object.optString("first_name");
                    LastNameSocial = object.optString("last_name");
                    GenderSocial = object.optString("gender");
                    EmailSocial = object.optString("email", "");
                    id = object.optString("id");


                    if (!EmailSocial.equals("")) {
                        login_type = Config.Login_Type_facebook;
                        callAPI(EmailSocial, id, "");

                    } else {
                        Toast.makeText(getApplicationContext(), "Permision Denied", Toast.LENGTH_LONG)
                                .show();
                    }

                }
            });

    Bundle parameters = new Bundle();
    parameters.putString("fields", "id,name,email,birthday,gender,first_name,last_name,picture,education,work");
    request.setParameters(parameters);
    request.executeAsync();

Might help someone ! Happy coding :)

Akanksha Rathore
  • 3,603
  • 3
  • 31
  • 47
3

Make sure you authorized with that permission: user_education_history

API call to get a list of education IDs: https://developers.facebook.com/tools/explorer/?method=GET&path=me%3Ffields%3Deducation

In your code, you need to replace the following string with one of the resulting education IDs: {education-experience-id}

For example:

new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/12345",
        null,
        HttpMethod.GET,
        new GraphRequest.Callback() {
            public void onCompleted(GraphResponse response) {
                Log.d("fb response",response.toString());
            }
        }
).executeAsync();
andyrandy
  • 72,880
  • 8
  • 113
  • 130
  • +1 for the good approach, as i mention my aim is to get education detail and work experience of user. Can you guide me more for this or send code. Description :- https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&path=%7Beducation-experience-id%7D&version=v2.6 – Akanksha Rathore May 27 '16 at 09:56
  • my answer should include everything you need to know, i am not sure what else you expect, to be honest? just open the link in my answer and make sure you authorized with the correct permission. that api call in the link gets you the list of education, there´s not much magic in it. it´s a simple get call to the graph api. – andyrandy May 27 '16 at 10:03
  • Thanks, your answer helped me too much :) – Akanksha Rathore May 27 '16 at 11:30