M
M
Mors Clamor2018-10-18 13:26:51
In contact with
Mors Clamor, 2018-10-18 13:26:51

VK API how to parse response in PHP?

Good day. So it came to the VK API, using cUrl I make a request

$response=json_decode(curl("https://oauth.vk.com/access_token?client_id=".APP_ID."&client_secret=".SECRET_KEY."&redirect_uri=адрес_тут&code=".$_GET["code"]));

The response is returned to me as a stdClass object. And how can this good be converted to an associative array or just parsed like that?
$array=array(array) $object
и
json_decode(json_encode($response))

They don't help. Thanks

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Konstantin Tolmachev, 2018-10-18
@66demon666

$result = json_decode($response);
$token = $result->access_token;  // access_token
$experies = $result->expires_in // expires_in
Ну и т.д.

D
Dies Irae, 2018-10-18
@YumeReaver

var_dump(json_decode($response, true));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question