Advertisement
kycok12345

Untitled

Jul 16th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.34 KB | None | 0 0
  1. public function request($method, $params = []) {
  2.         list($method, $params) = $this->editRequestParams($method, $params);
  3.         $url = 'https://api.vk.com/method/' . $method;
  4.         $params['access_token'] = $this->token;
  5.         $params['v'] = $this->version;
  6.         $params += $this->differenceVersions($method);
  7.  
  8.         while (True) {
  9.             try {
  10. //              echo "Попытка отправить запрос...\n";
  11.                 return $this->request_core($url, $params);
  12.             } catch (VkApiException $e) {
  13.                 sleep(1);
  14.                 $exception = json_decode($e->getMessage(), true);
  15.                 if (in_array($exception['error']['error_code'], $this->request_ignore_error)) {
  16.                     continue;
  17.                 } elseif ($exception['error']['error_code'] == 14) {
  18.  
  19.                     $captcha_img = $exception['error']['captcha_img'];
  20.  
  21.                     $captchaText = $this->testImageToText($captcha_img);
  22.  
  23.                     $params['captcha_sid'] = $exception['error']['captcha_sid'];
  24.                     $params['captcha_key'] = $captchaText;
  25.                     return $this->request_core($url, $params);
  26.                 } else {
  27.                     throw new VkApiException($e->getMessage());
  28.                 }
  29.             }
  30.         }
  31.         return false;
  32.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement