Answer the question
In order to leave comments, you need to log in
How to remove the error when working with file_get_contents?
I’m asking the 2nd question with errors for this code, alas, I can’t solve the problem on my own, please help
$params = array(
'client_id' => '0000000',
'client_secret' => '11111111111111111111111',
'redirect_uri' => 'url_red',
'code' => $_GET['code']
);
$token = file_get_contents('https://oauth.vk.com/access_token?' . http_build_query($params, null, '&'));
//ответ будет такой {"access_token":"****","expires_in":"*****","user_id":"*****","email":"****"}
$token = json_decode($token, true);
$id = $token['user_id'];
$data = file_get_contents('https://api.vk.com/method/users.get?user_ids=' . $token['user_id'] . '&lang=0&fields=photo_50,city,sex&v=5.60');
$data = json_decode($data, true);
$data = current($data['response']);
//"{"response":[{"id":**,"first_name":"***","last_name":"**","photo_100":"****","hidden":1}]}"
Answer the question
In order to leave comments, you need to log in
If you carefully look at the text of the error, moreover, if you just go to the URL indicated in the error, it will become clear that the protocol used (http) is not suitable for authorization, which Angular apparently does not know about, see where your ang messes up with the request.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question