如何在登录响应中获取Facebook照片URL?

时间:2018-02-13 15:28:29

标签: android facebook-graph-api facebook-login

我正在获取大量照片,我希望有相关网址,请参阅下面的代码。

 callbackManager = CallbackManager.Factory.create();
    LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            GraphRequest request = GraphRequest.newMeRequest(
                    loginResult.getAccessToken(),
                    new GraphRequest.GraphJSONObjectCallback() {
                        @Override
                        public void onCompleted(JSONObject object, GraphResponse response) {
                            parseFbResponse(object);
                        }
                    });

            Bundle parameters = new Bundle();
            parameters.putString("fields", "id,name,email,birthday,work,about,photos.limit(6){link}");
            request.setParameters(parameters);
            request.executeAsync();

回应 -

{}photos
  []data
    {}0
      created_time : "2017-12-25T07:04:31+0000"
      name : "♥️♥️♥️♥️"
      id : "2534011966656881"

1 个答案:

答案 0 :(得分:-1)

  /* make the API call */
    new GraphRequest(
        AccessToken.getCurrentAccessToken(),
        "/{photo-id}",
        null,
        HttpMethod.GET,
        new GraphRequest.Callback() {
            public void onCompleted(GraphResponse response) {
                /* handle the result */
            }
        }
    ).executeAsync();

有关photo element的更多参考,请参阅图api文档。 https://developers.facebook.com/docs/graph-api/reference/photo/

https://developers.facebook.com/docs/graph-api/reference/user/photos/