M
M
Mvmolkov2018-11-23 08:11:44
PHP
Mvmolkov, 2018-11-23 08:11:44

How to avoid error 500 when working with VK API?

Hi people.
I have such a problem, when working with vk api through php, an error 500 crashes when the request cannot be completed.
Now more.
I use the official VKSDK PHP library, and when I use, for example, the method to display statistics for a group (not to my own, i.e. I do not have the right to request statistics), my browser gives an error 500. The
request is correct, because. when requesting your group's "All is well" statistics.
Does anyone know how to fix this?
And maybe there are better libraries for working with all methods?
Thank you all in advance. I'll attach the code if needed.
Code example.

<?php
 
require __DIR__ . '/vendor/autoload.php';
 
$vk = new VK\Client\VKApiClient('5.87');
$access_token = 'ХХХХХХХХХХХХХХХ';

if ($_POST['submit']){

$response = $vk->groups()->getById($access_token, array(
    'group_ids' => array($_POST['group'])
));

  echo "<pre>";
  print_r($response);
  echo "</pre>";


}
?>
<!DOCTYPE html>
<html lang="">
<head>
  <meta charset="UTF-8">
  <title>Информация о группе</title>
</head>
<body>

<form action="" method="post">
  <input type="text" name="group">
  <input type="submit" name="submit" value="Отправить">
</form>
</body>
</html>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem, 2018-11-23
@Mvmolkov

If 500 is issued by the browser, and not vk api, then you need to watch the server logs, or enable the display of errors. This will help you find the place where the error occurs.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question