G
G
Genri_Rus2020-01-08 19:18:03
PHP
Genri_Rus, 2020-01-08 19:18:03

Why can't get countries api vk?

I get countries like this:

$lang = 0; // russian
$headerOptions = array(
  'https' => array(
    'method' => "GET",
    'header' => "Accept-language: en\r\n" .
    "Cookie: remixlang=$lang\r\n"
  )
);

$methodUrl = 'https://api.vk.com/method/database.getCountries?v=5.103&need_all=1&count=1000';
$streamContext = stream_context_create($headerOptions);
$json = file_get_contents($methodUrl, false, $streamContext);
print_r($json);

But I get this error:
{"error":{"error_code":5,"error_msg":"User authorization failed: no access_token passed.","request_params":[{"key":"v","value":"5.103"},{"key":"need_all","value":"1"},{"key":"count","value":"1000"},{"key":"method","value":"database.getCountries"},{"key":"oauth","value":"1"}]}}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladislav Zelenyuk, 2020-01-10
@zelvad

Put access_token in header

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question