D
D
Dmitry2019-02-05 17:41:04
PHP
Dmitry, 2019-02-05 17:41:04

What is the reason for getting error from VK API "Access denied"?

I can’t understand what is the reason, I use this code to get data about the group:

$request_params = array( 
          'group_id' => $id, 
          'access_token' => env('VK_ACCESS_TOKEN'),
          'v' => '5.92' 
        );				
        $get_params = http_build_query($request_params); 
        $result = json_decode(file_get_contents('https://api.vk.com/method/groups.getById?'. $get_params), true);

Everything is ok, I receive data without problems.
Now I call the method to get the list of subscribers with the same token as above in the code
$request_params = array( 
          'group_id' => $id, 
          'count' => 0, 
          'access_token' => env('VK_ACCESS_TOKEN'),
          'v' => '5.92' 
        );				
        $get_params = http_build_query($request_params); 
        $result = json_decode(file_get_contents('https://api.vk.com/method/groups.getMembers?'. $get_params), true);

and here on you, the error "Access denied" I
use the community access key.
Where is the mistake? already tired!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2019-02-06
@liggth

I don’t know what’s the matter, but in order to get VK group subscribers via API, you need to use not the group key and not the Standalone application key (I have several IP addresses, so the option didn’t work), but use the Standalone application service key. Only in this case I got a list of subscribers.5c5a936b0190c510264763.png

S
Sergey S., 2019-02-06
@seganim

1. count - the number of community members, information about which you need to get.
positive number, default 1000, maximum value 1000.
Are you sure that setting 0 will remove the limit?
2. At the time of the second request, print $id and env('VK_ACCESS_TOKEN'), do they match?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question