Answer the question
In order to leave comments, you need to log in
Curl for oauth.vk.com
Good evening!
Help, please, I've been trying to get an access_token from VK all day.
Here is the code I tried:
$c = file_get_contents('https://oauth.vk.com/access_token?client_id={id}&client_secret={key}&code='.$code.'&redirect_uri={site}');
Warning: file_get_contents(https://oauth.vk.com/access_token?client_id={id}..): failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized in ...
Answer the question
In order to leave comments, you need to log in
Hey!
Just today I was interested in this issue myself, and found this solution:
function get_curl($url) {
if(function_exists('curl_init')) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$output = curl_exec($ch);
echo curl_error($ch);
curl_close($ch);
return $output;
} else {
return file_get_contents($url);
}
}
And you apply this function to your link instead of file_get_contents.
https://oauth.vk.com/authorize?client_id='+String(VK_APP_ID)+'&scope=offline&redirect_uri=https://oauth.vk.com/blank.html=mobile&response_type=token
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question