SHARE
TWEET

Untitled

a guest Jan 26th, 2019 124 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function tokenVK($login, $password, $atom) {
  2. $token_url = $atom->request([
  3.     'url' => 'https://oauth.vk.com/token?grant_type=password&client_id=2274003&client_secret=hHbZxrka2uZ6jB1inYsH&username='.$login.'&password='.$password,
  4.     'no_headers' => true,
  5. ]);
  6. $token_url = json_decode($token_url);
  7. //-----------------Ввод капчи, если запросили--------------
  8. if($token_url->captcha_sid){
  9. $ch = curl_init($result->captcha_img);
  10. $fp = fopen('captcha.png', 'wb');
  11. curl_setopt($ch, CURLOPT_FILE, $fp);
  12. curl_setopt($ch, CURLOPT_HEADER, 0);
  13. curl_exec($ch);
  14. curl_close($ch);
  15. fclose($fp);
  16. $imgcap = 'captcha.png';
  17.         try {
  18.     $code = $atom->ruCaptcha($imgcap, [
  19.         'regsense' => 1,
  20.     ]);
  21. }
  22. catch (Exception $e) {
  23.     $error_capt = 'Выброшено исключение: '. $e->getMessage();
  24. }
  25. $token_url = $atom->request([
  26.     'url' => 'https://oauth.vk.com/token?grant_type=password&client_id=2274003&client_secret=hHbZxrka2uZ6jB1inYsH&username='.$login.'&password='.$password.'&captcha_sid='.$result->captcha_sid.'&captcha_key='.$code,
  27.     'no_headers' => true,
  28. ]);
  29. $token_url = json_decode($token_url);
  30. }
  31. elseif ($token_url->error_description){
  32.     echo "Ошибка данных!!!";
  33.     return;
  34. }
  35. test($token_url);
  36. unlink(__DIR__ .'/tmp/atomic.cookie');
  37. return $token_url->access_token;
  38. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top