Answer the question
In order to leave comments, you need to log in
How to write data from VK request to database?
Here is the answer to the request from VK -
Array ( [response] => Array ( [0] => Array ( [first_name] => Виталий [id] => 334626026 [last_name] => Милеев [can_access_closed] => 1 [is_closed] => [sex] => 2 ) ) )
$query = "INSERT INTO `user`(`user_id`,`sex`) VALUES ($user_id,'".$result['sex']."')";
$request_params = array(
'user_ids' => '334626026',
'access_token' => '123123',
'fields' => 'sex',
'v' => '5.131'
);
$date = http_build_query($request_params);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $date);
curl_setopt($ch, CURLOPT_URL,"https://api.vk.com/method/users.get?");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
$result = json_decode($result, 1);
Answer the question
In order to leave comments, you need to log in
Work out the skill of how to insert something into the database at all.
For example, like this https://html5css.ru/php/php_mysql_insert.php
Please note that the process of interacting with the database has several phases of work:
connecting to the database, creating a query, adding parameters to the query, executing the query and getting the result (if needed) action status or selection).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question