I
I
Ilya Beloborodov2016-01-29 18:35:24
PHP
Ilya Beloborodov, 2016-01-29 18:35:24

vk api. Why doesn't it return all fields?

There is a users.getSubscriptions method that displays which communities the user is a member of.
If you test in the developer section, then VK gives this

response: {
 count: 76,
 items: [{
  id: 57876954,
  name: 'Vine Video',
  screen_name: 'vinevinevine',
  is_closed: 0,
  type: 'page',
  is_admin: 0,
  is_member: 1,
  photo_50: 'http://cs425327.v...6bb/Zu_yFZL4dXg.jpg',
  photo_100: 'http://cs425327.v...6ba/ttuRoe42pnE.jpg',
  photo_200: 'http://cs425327.v...6b9/8M2hy2j1vOA.jpg'
}, {
 id: 7177686, .......

But in fact, VK returns the same, but without the is_admin and is_member fields I need .
Send like this
public function getGroupUser($id_user){
        $method='https://api.vk.com/method/users.getSubscriptions?';
        $data=[
            'count'=>20,
            'user_id'=>$id_user,
            'extended'=>1,
            'fields'=>'is_admin,is_member'
        ];
        return json_decode(file_get_contents($method.urldecode(http_build_query($data))),true);
    }

update:
Also, there is a group.get method which also does not return the required fields. And it requires an access_token (although the doc says it doesn't)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya Beloborodov, 2016-01-29
@kowap

All decided. Need access_token + pass admin in the filter parameter

public function getGroupUser($id_user,$token){
        $method='https://api.vk.com/method/groups.get?';
        $data=[
            'count'=>200,
            'user_id'=>$id_user,
            'extended'=>1,
            'filter'=>'admin',
            'access_token'=>$token,
        ];
        return json_decode(file_get_contents($method.urldecode(http_build_query($data))),true);
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question