<?if (!$_GET['code']) {
exit('error code');}
include 'config.php';
$token = json_decode(file_get_contents('https://oauth.vk.com/access_token?client_id='.ID.'&redirect_uri='.URL.'&client_secret='.SECRET.'&code='.$_GET['code']),
true);
if (!$token) {
exit('error token');
}
$data = json_decode(file_get_contents('https://api.vk.com/method/users.get?user_id='.$token['user_id'].'&access_token='.$token['access_token'].'&fields=uid
,first_name,last_name,photo_big'), true);
if (!$data) {
exit('error data');
}
$data = $data['response'][0];
echo '<pre>';
var_dump($data);
echo '</pre>';
?>
выдает ошибку:
file_get_contents(https://oauth.vk.com/access_token?client_id=620**57&redirect_uri=https://mysite/vk.php&client_secret=7*****IFrku32EloUowf1&code=8d6b63f6d8f5d454d7): failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized in Z:\home\mysite\www\vk.php on line 9 error token
php файл с константами
define('ID', '*******');
define('SECRET', '**********');
define('URL', 'https://mysite/vk.php');
Делал по примеру, что неправильно уже пол дня не могу понять
id
иsecret
стоит публиковать открыто?