Log in to URL:

https://oauth.vk.com/authorize?client_id=(СКРЫТО)&display=popup&redirect_uri=http://w-0rld.ru/index.php&response_type=code 

I get a token:

 if (isset($_GET['code'])) { $token = file_get_contents("https://oauth.vk.com/access_token?client_id=(СКРЫТО)&client_secret=(СКРЫТО)&redirect_uri=http://w-0rld.ru/index.php&code=".$_GET['code']); $token_GET = json_decode($token); $token = $token_GET->access_token; $id = $token_GET->user_id; setcookie("token",$token,time()+3600); // Ставим куку на час ибо через час код будет не рабочим. setcookie("id",$id,time()+3600); header("Location: /"); } 

So far, everything is smooth, but as I begin to receive audio:

 if($_GET['json'] AND $_GET['mode'] == 'audios') { header('Content-Type: application/json'); $list = file_get_contents('https://api.vk.com/method/audio.get?owner_id='.$_COOKIE['id'].'&count=81&access_token='.$_COOKIE['token']); exit ($list); } 

There is an error:

 {"error":{"error_code":15,"error_msg":"Access denied: no access to call this method","request_params":[{"key":"oauth","value":"1"},{"key":"method","value":"audio.get"},{"key":"owner_id","value":"171166379"},{"key":"count","value":"81"}]}} 

    1 answer 1

    The code is ok, the API itself tells you that "there is no access to calling this method." Go to the official API documentation, find the method and read the following there:

    Permissions required: audio.

    Therefore, in the authorization request you need to add scope, since you need to request permission to use

     &scope=audio 

    For more information about access rights and authorization parameters, which will be useful for further development, see the official documentation in the section on site authorization.

    • Missed the point in the docks. Thanks for the quick response! - W_0rld pm