V
V
Vitalya Orlin2017-10-06 19:21:04
JSON
Vitalya Orlin, 2017-10-06 19:21:04

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 ' '%20.%20$userInfo%5B'photo_big'%5D%20.%2'; 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

1 answer(s)
D
DevMan, 2017-10-06
@a_hooligan

because it shouldn't - curl_init returns the curl handler, not jason. about what actually also is spoken in an error.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question