Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing RestTemplate Facebook Graph API response email field is intermitent. But with a hand made call it is present
    primarykey
    data
    text
    <p>I'm developing a REST service using Java with Spring, that connects to Facebook and gets some user data like name, last_name, and the most important: <strong>email</strong>. </p> <p>The service has a method that expects Facebook uid and the access token, and then it gets the user info by calling to <a href="https://graph.facebook.com/me/?fields=email,id,last_name,name&amp;access_token=XXXXX" rel="nofollow noreferrer">https://graph.facebook.com/me/?fields=email,id,last_name,name&amp;access_token=XXXXX</a> and parsing the json response.</p> <p>The problem is that some users have no email in the response.. I know that there are facebook users who haven't set an email, because they create their account using a phone number. That's not the problem here.</p> <p>When I use <strong>RestTemplate</strong> class, the email is not in the response, but when I use the <strong>Graph API Explorer</strong> tool (<a href="https://developers.facebook.com/tools/explorer/" rel="nofollow noreferrer">https://developers.facebook.com/tools/explorer/</a>), the email is there.</p> <p><br></p> <h3>With RestTemplate:</h3> <pre><code>RestTemplate rest = new RestTemplate(); String jsonResponse = rest.getForObject("https://graph.facebook.com/me/?fields=" + fields + "&amp;access_token=" + accessToken, String.class); JSONObject o = JSONObject.fromObject(jsonResponse); </code></pre> <p><br></p> <h3>Response with RestTemplate:</h3> <pre><code>{ "id": "xxxxxxxx", "last_name": "Avila", "name": "Diego Emanuel Avila" } </code></pre> <p><br></p> <h3>Response with Graph API Explorer</h3> <pre><code>{ "id": "xxxxxxxx", "email": "xxxxxx@gmail.com" "last_name": "Avila", "name": "Diego Emanuel Avila" } </code></pre> <p><br> <br> I don't know if the problem is in RestTemplate class, or in Facebook Graph API.. I don't know if I have to add a header or something like that, to get the right response from Facebook.</p> <p>Looking for an answer here, I stumbled upon with this <a href="https://stackoverflow.com/questions/7603644/intermittent-missing-email-address-in-facebook-api">Intermittent missing email address in facebook API</a>, but it's not the same issue as mine.</p> <p><br> I hope I made myself clear and you can help me out with this.</p> <p>Thanks a lot!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload