Answer the question
In order to leave comments, you need to log in
Warning: json_decode() expects parameter 1 to be string, resource given..?
$client_id = '';
$client_secret = '';
$redirect_uri = '';
$url = ' oauth.vk.com/authorize ';
$params = array(
'client_id' => $client_id,
'redirect_uri' => $redirect_uri,
'response_type' => 'code'
);
echo $link = ' Authentication via VKontakte ';
if(isset($_GET['code'])) {
$result = false;
$params = array(
'client_id' => $client_id,
'client_secret' => $client_secret,
'code' => $_GET['code'],
'redirect_uri' => $redirect_uri
);
' . '?' . urldecode(http_build_query($params))), true);
if (isset($token['access_token'])) {
$params = array(
'uids' => $token['user_id'],
'fields' => 'uid,first_name,last_name,screen_name,sex,bdate, photo_big',
'access_token' => $token['access_token']
);
$userInfo = json_decode(curl_init(' https://api.vk.com/method/users.get ' . '?' . urldecode(http_build_query($params))), true);
if(isset($userInfo['response'][0]['uid'])) {
$userInfo = $userInfo['response'][0];
$result = true;
}}
if ($result) {
echo "User Social ID:
echo "Username: " . $userInfo['first_name'] . '
';
echo "Link to user profile: " . $userInfo['screen_name'] . '
';
echo "User gender: " . $userInfo['sex'] . '
';
echo "Birthday: " . $userInfo['bdate'] . '
';
echo ' '; echo "
";
}
}
I can't figure out why json_decode() doesn't work?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question