A
A
Alexander Farber2015-10-15 23:28:58
Android
Alexander Farber, 2015-10-15 23:28:58

VK API for Android: why does camera_b.gif or null come instead of photo_big?

Hello, in an android application, I'm trying to get the name, city and large photo of the user of this application:

private final static String FIELDS = "photo,city,sex";
    //private final static String FIELDS = "photo_big,city,sex";

    private VKCallback<VKAccessToken> mCallback = new VKCallback<VKAccessToken>() {
        @Override
        public void onResult(VKAccessToken res) {
            VKRequest request = VKApi.users().get(VKParameters.from(VKApiConst.FIELDS, FIELDS));
            request.executeWithListener(mRequestListener);
        }
    };

    private VKRequest.VKRequestListener mRequestListener = new VKRequest.VKRequestListener() {
        @Override
        public void onComplete(VKResponse response) {
            try {
                VKList<VKApiUserFull> list = (VKList<VKApiUserFull>) response.parsedModel;
                VKApiUserFull user = list.get(0);
                String sid = String.valueOf(user.id);
                String given = user.first_name;
                String family = user.last_name;
                String photo = user.photo_200;
                String place = (user.city != null ? user.city.title : "");
                boolean female = (user.sex == VKApiUserFull.Sex.FEMALE);
                // update UI
            } catch (Exception e) {
            }
        }
    };

    @Override
    public void onClick(View v) {
        VKSdk.login(getActivity());
    }

In the debugger, I see response.responseString (I changed my id below and I'm not banned):
{"response":[
{"id":59751333,
"first_name":"Alexander",
"last_name":"Farber",
"sex":2,
"city":{"id":1945522,"title":"Bochum"},
"photo":"https:\/\/pp.vk.me\/c319319\/v319319333\/b7e3\/n-yDMG4lvvk.jpg"
}]}

But alas, I can't find the "photo" value in my VKApiUserFull object:
  • user.photo_100 contains vk.com/images/camera_b.gif
  • user.photo_50 contains vk.com/images/camera_c.gif
  • user.photo_200 is generally null

Where can I get a real big user avatar, that is, in my example https://pp.vk.me/c319319/v319319333/b7e3/n-yDMG4lv... ?
I tried photo and photo_big , I also searched on GitHub in the VK SDK ...
Thanks (I changed my id above, since I still need it to generate a hash in a mobile application).
UPDATE 2:
VK SDK fixed this bug in version 1.6.2 and added fields there
public final static String FIELD_PHOTO_400_ORIGIN = "photo_400_orig";
public final static String FIELD_PHOTO_MAX = "photo_max";
public final static String FIELD_PHOTO_MAX_ORIGIN = "photo_max_orig";
public final static String FIELD_PHOTO_BIG = "photo_big";

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
LeEnot, 2015-10-16
@afarber

Well, you don't ask them...

private final static String FIELDS = "photo, photo_50, photo_100, photo_200, city, sex";

A
Alexander Farber, 2015-10-16
@afarber

Well, apparently the answer is: photo_50 , photo_100 , photo_200 can be obtained through the VkApiUserFull object.
The remaining (and larger) photos of the VK user will have to be retrieved via JSONObject: photo_400 , photo_max , photo_max_orig and (obsolete?) photo_big .
Here is an example of my info (id changed):

{"response":[{"id":59751333,
"first_name":"Alexander",
"last_name":"Farber",
"sex":2,
"city":{"id":1945522,"title":"Bochum"},
"photo":"https:\/\/pp.vk.me\/c319319\/v319319333\/b7e3\/n-yDMG4lvvk.jpg",
"photo_50":"https:\/\/pp.vk.me\/c319319\/v319319333\/b7e3\/n-yDMG4lvvk.jpg",
"photo_100":"https:\/\/pp.vk.me\/c319319\/v319319333\/b7e2\/Kt5-Wj2Ffv4.jpg",
"photo_200":"https:\/\/pp.vk.me\/c319319\/v319319333\/b7e1\/oJrjeeYO44I.jpg",
"photo_max":"https:\/\/pp.vk.me\/c319319\/v319319333\/b7e1\/oJrjeeYO44I.jpg",
"photo_big":"https:\/\/pp.vk.me\/c319319\/v319319333\/b7df\/TnyKeffL_mU.jpg",
"photo_max_orig":"https:\/\/pp.vk.me\/c319319\/v319319333\/b7e0\/Zg6YbDQnqiM.jpg"
}]}

I created a new issue on GitHub about this .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question