Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save burakaydn/6370941 to your computer and use it in GitHub Desktop.
Save burakaydn/6370941 to your computer and use it in GitHub Desktop.
Bundle bundle = new Bundle();
bundle.putString("fields", "picture.type(large),quotes,email,first_name,last_name,username");
final Request request = new Request(ParseFacebookUtils.getSession(),
"me", bundle, HttpMethod.GET, new Request.Callback() {
@Override
public void onCompleted(Response response) {
GraphObject graphObject = response.getGraphObject();
if (graphObject != null) {
//Parse graphObject to User
JSONObject jsonUser = graphUser.getInnerJSONObject();
try {
mUser.setEmail(jsonUser.getString(EMAIL));
mUser.setImageUri(jsonUser.getJSONObject("picture").getJSONObject("data").getString("url"));
mUser.setName(jsonUser.getString("first_name"));
mUser.setSurname(jsonUser.getString("last_name"));
mUser.setUsername(jsonUser.getString("username"));
} catch (JSONException e) {
Log.e(TAG, e.toString());
e.printStackTrace();
}
}
}
});
Request.executeBatchAsync(request);
@indiTechCoder
Copy link

what would be the code for SDK 4.0 i am stuck here to capture profile image url

{
// App code
GraphRequest request = GraphRequest.newMeRequest(
loginResult.getAccessToken(),
new GraphRequest.GraphJSONObjectCallback() {
@OverRide
public void onCompleted(
JSONObject object,
GraphResponse response) {
Log.v("LoginActivity", response.toString());
try {
// GraphObject graphObject = response.getGraphObject();

                                Log.v("Name:", response.getJSONObject().get("name").toString());
                                Toast.makeText(getApplicationContext(), "Welcome " + response.getJSONObject().get("name").toString() +
                                                "\n" + response.getJSONObject().get("email").toString(),
                                        Toast.LENGTH_LONG).show();
                                fbUser user = new fbUser();
                                user.setEmail(response.getJSONObject().get("email").toString());
                                user.setName(response.getJSONObject().get("name").toString());
                                user.setImageUri(response.getJSONObject().get("picture").toString());
                                startActivity(new Intent(ActivityLogin.this, MainActivity.class));
                            } catch (JSONException e) {
                                e.printStackTrace();
                            }
                        }
                    });
            Bundle parameters = new Bundle();
            parameters.putString("fields", "id,name,email");
            request.setParameters(parameters);
            request.executeAsync();
        }

@DebdeepNandy
Copy link

how to all prfile picture of a user in android

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment