Advertisement
Guest User

Untitled

a guest
Jul 30th, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
  2. @Override
  3. public void onSuccess(LoginResult loginResult) {
  4.  
  5. GraphRequest request = GraphRequest.newMeRequest(
  6. loginResult.getAccessToken(),
  7. new GraphRequest.GraphJSONObjectCallback() {
  8. @Override
  9. public void onCompleted(
  10. JSONObject object,
  11. GraphResponse response) {
  12. // Application code
  13.  
  14. try {
  15. JSONObject jsonObject = new JSONObject(response.toString());
  16.  
  17.  
  18.  
  19. } catch (JSONException e) {
  20. e.printStackTrace();
  21. }catch (NullPointerException e){
  22.  
  23. }
  24.  
  25.  
  26.  
  27. }
  28. });
  29. Bundle parameters = new Bundle();
  30. parameters.putString("fields", "id,name,email,gender, birthday");
  31. request.setParameters(parameters);
  32. request.executeAsync();
  33.  
  34. }
  35.  
  36.  
  37.  
  38. @Override
  39. public void onCancel() {
  40. Log.e("facebook","canceled");
  41. }
  42.  
  43. @Override
  44. public void onError(FacebookException e) {
  45.  
  46. Log.e("facebook error",e.getMessage().toString());
  47. }
  48. });
  49.  
  50. {Response: responseCode: 200, graphObject: {"id":"931177080295510","birthday":"06/24/1991","gender":"male","email":"smemamian@yahoo.com","name":"Masoud Emamian"}, error: null}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement