V
V
vision-bk2016-11-27 02:52:27
Android
vision-bk, 2016-11-27 02:52:27

Android VK API How to get information about a user's friend by id?

I manage to get the list of required fields by friends via

VKApi.friends().get(VKParameters.from(VKApiConst.FIELDS,"id,first_name,last_name,photo_100,photo_max_orig,online,status"));

According to the vk api documentation, the list of available fields in the request for friends().get() is limited, and I need to display each friend, for example, the number of his friends.
I am trying to do it like this:
VKRequest request = VKApi.users().get(VKParameters.from(VKid,VKApiConst.FIELDS,"counters"));
request.executeWithListener(new VKRequest.VKRequestListener() {
            @Override
            public void onComplete(VKResponse response) {
                super.onComplete(response);
                VKList list =  (VKList) response.parsedModel;
                String s = list.get(0).fields.toString();
            }
        });

but the debugger shows that there is only one entry in the list, and the string s contains information about me (that is, about the current current user).
The documentation describes that you can pass user IDs to users().get() , and if there are none, data about the current user is returned by default. The friend id I am passing in is initialized correctly.
Perhaps I somehow incorrectly pass the id of the user I'm interested in to users().get(), or I misunderstand the true purpose of this method.
I also can't find examples using users().get() in the way I want.
I would like to see a working example that implements my request.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Oleg Gamega, 2016-11-27
@vision-bk

Maybe I'm somehow incorrectly passing the id of the user I'm interested in to users().get()

Where is user_ids actually in your code?
users.get

R
Rou1997, 2016-11-27
@Rou1997

To see a working example for any request - you want a lot, learn to work with documentation and learn how to debug, the VK SDK for Android is just a "wrapper" for the usual VK API that works via HTTP (except for the procedure for obtaining a token, which is simplified on android) , therefore, also use the documentation for this API, and use the sniffer and the source code of the "wrapper" to debug it and understand what is being parsed and where.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question